Passed
Push — 5.0 ( d46d5f )
by Luis
39s queued 12s
created

Attribute::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 2
cts 2
cp 1
crap 1
rs 10
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 147
{
26
    use WithVisibility;
27 147
    use WithStaticModifier;
28 147
    use WithVariable;
29 147
30 147
    public function __construct(Variable $variable, Visibility $modifier, bool $isStatic = false)
31
    {
32 81
        $this->variable = $variable;
33
        $this->modifier = $modifier;
34 81
        $this->isStatic = $isStatic;
35
    }
36
37 84
    /** @return Name[] */
38
    public function references(): array
39 84
    {
40
        return $this->variable->references();
41
    }
42 105
43
    public function __toString(): string
44 105
    {
45
        return sprintf(
46
            '%s%s',
47 60
            $this->modifier,
48
            $this->variable
49 60
        );
50 60
    }
51
}
52