Completed
Push — master ( 3f1b14...d7a449 )
by Luis
14:49 queued 04:53
created

Attribute::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Code;
9
10
class Attribute extends Variable
11
{
12
    private static $symbols = [
13
        'private' => '-',
14
        'public' => '+',
15
        'protected' => '#',
16
    ];
17
18
    /** @var string */
19
    public $modifier;
20
21
    public function __construct(string $name, string $modifier = 'public', string $type = null)
22
    {
23
        parent::__construct($name, $type);
24
        $this->modifier = $modifier;
25
    }
26
27
    /**
28
     * It doesn't currently support information type
29
     *
30
     * @see plGraphvizProcessor#getClassDefinition In its original version
31
     */
32
    public function __toString()
33
    {
34
        return sprintf('%s%s', self::$symbols[$this->modifier], $this->name);
35
    }
36
}
37