Field.php 1.35 KB
Newer Older
1
<?php declare(strict_types=1);
2
/*
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
3
4
 * Copyright (C) 2016-2017 IRSTEA
 * All rights reserved.
5
6
7
8
9
10
11
12
 */

namespace Irstea\PlantUmlBundle\Doctrine;

use Irstea\PlantUmlBundle\Model\Node\Member\Member;
use Irstea\PlantUmlBundle\Writer\WriterInterface;

/**
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
13
 * Description of Field.
14
15
16
17
 */
class Field extends Member
{
    /**
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
18
     * @var bool
19
20
21
22
     */
    private $isUnique;

    /**
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
23
     * @var bool
24
25
26
27
     */
    private $isNullable;

    /**
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
28
     * @var bool
29
30
31
32
33
34
     */
    private $isIdentifier;

    public function __construct($symbol, $type, $isUnique = false, $isNullable = false, $isIdentifier = false)
    {
        parent::__construct($symbol, $type);
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
35
36
        $this->isUnique = $isUnique;
        $this->isNullable = $isNullable;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
        $this->isIdentifier = $isIdentifier;
    }

    protected function writeSymbolTo(WriterInterface $writer)
    {
        if ($this->isIdentifier) {
            $writer->write('<b>');
        }
        if (!$this->isNullable) {
            $writer->write('<i>');
        }
        if ($this->isUnique) {
            $writer->write('<u>');
        }
        parent::writeSymbolTo($writer);
        if ($this->isUnique) {
            $writer->write('</u>');
        }
        if (!$this->isNullable) {
            $writer->write('</i>');
        }
        if ($this->isIdentifier) {
            $writer->write('</b>');
        }
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
61

62
63
64
        return $this;
    }
}