Property::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
4
 */
5
6
namespace PhUml\Code\Properties;
7
8
use PhUml\Code\Modifiers\CanBeStatic;
9
use PhUml\Code\Modifiers\HasVisibility;
10
use PhUml\Code\Modifiers\Visibility;
0 ignored issues
show
Bug introduced by
The type PhUml\Code\Modifiers\Visibility was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use PhUml\Code\Modifiers\WithStaticModifier;
12
use PhUml\Code\Modifiers\WithVisibility;
13
use PhUml\Code\Name;
14
use PhUml\Code\Variables\HasType;
15
use PhUml\Code\Variables\Variable;
16
use PhUml\Code\Variables\WithVariable;
17
use Stringable;
18
19
/**
20
 * It represents an instance variable
21
 */
22
final class Property implements HasType, HasVisibility, CanBeStatic, Stringable
23
{
24
    use WithVisibility;
25
    use WithStaticModifier;
26
    use WithVariable;
27
28 51
    public function __construct(Variable $variable, Visibility $visibility, bool $isStatic = false)
29
    {
30 51
        $this->variable = $variable;
0 ignored issues
show
Bug introduced by
The property variable is declared read-only in PhUml\Code\Properties\Property.
Loading history...
31 51
        $this->visibility = $visibility;
0 ignored issues
show
Bug introduced by
The property visibility is declared read-only in PhUml\Code\Properties\Property.
Loading history...
32 51
        $this->isStatic = $isStatic;
33
    }
34
35
    /** @return Name[] */
36 14
    public function references(): array
37
    {
38 14
        return $this->variable->references();
39
    }
40
41 14
    public function __toString(): string
42
    {
43 14
        return sprintf(
44
            '%s%s',
45 14
            $this->visibility->value,
46 14
            $this->variable
47
        );
48
    }
49
}
50