Passed
Push — union-types ( cd7236...b93e9c )
by Luis
10:52
created

Attribute::references()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.0
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\Attributes;
9
10
use PhUml\Code\Modifiers\CanBeStatic;
11
use PhUml\Code\Modifiers\HasVisibility;
12
use PhUml\Code\Modifiers\Visibility;
13
use PhUml\Code\Modifiers\WithStaticModifier;
14
use PhUml\Code\Modifiers\WithVisibility;
15
use PhUml\Code\Name;
16
use PhUml\Code\Variables\HasType;
17
use PhUml\Code\Variables\Variable;
18
use PhUml\Code\Variables\WithVariable;
19
use Stringable;
20
21
/**
22
 * It represents an instance variable
23
 */
24
final class Attribute implements HasType, HasVisibility, CanBeStatic, Stringable
25
{
26
    use WithVisibility;
27
    use WithStaticModifier;
28
    use WithVariable;
29
30
    public function __construct(Variable $variable, Visibility $modifier, bool $isStatic = false)
31
    {
32
        $this->variable = $variable;
33
        $this->modifier = $modifier;
34
        $this->isStatic = $isStatic;
35
    }
36
37
    /** @return Name[] */
38
    public function references(): array
39
    {
40
        return $this->variable->references();
41
    }
42
43
    public function __toString(): string
44
    {
45
        return sprintf(
46
            '%s%s',
47
            $this->modifier,
48
            $this->variable
49
        );
50
    }
51
}
52