Passed
Pull Request — master (#30)
by
unknown
46:28 queued 21:27
created

Constant::references()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
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\HasVisibility;
9
use PhUml\Code\Modifiers\Visibility;
10
use PhUml\Code\Modifiers\WithVisibility;
11
use PhUml\Code\Name;
12
use PhUml\Code\Variables\HasType;
13
use PhUml\Code\Variables\TypeDeclaration;
14
use PhUml\Code\Variables\WithTypeDeclaration;
15
use Stringable;
16
17
final class Constant implements HasType, HasVisibility, Stringable
18
{
19
    use WithTypeDeclaration;
20
    use WithVisibility;
21
22 27
    public function __construct(private readonly string $name, TypeDeclaration $type, Visibility $visibility)
23
    {
24 27
        $this->type = $type;
25 27
        $this->visibility = $visibility;
0 ignored issues
show
Bug introduced by
The property visibility is declared read-only in PhUml\Code\Properties\Constant.
Loading history...
26
    }
27
28 13
    public function __toString(): string
29
    {
30 13
        return sprintf(
31
            '%s%s%s',
32 13
            $this->visibility->value,
33 13
            $this->name,
34 13
            $this->type->isPresent() ? ": {$this->type}" : ''
35
        );
36
    }
37
38
    /** @return Name[] */
39 1
    public function references(): array
40
    {
41 1
        return []; // Constants can only be built-in types
42
    }
43
}
44