Passed
Push — master ( 1ba30a...8ac47c )
by Luis
01:05 queued 12s
created

Constant   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 7 2
A references() 0 3 1
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;
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...
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 28
    public function __construct(private readonly string $name, TypeDeclaration $type, Visibility $visibility)
23
    {
24 28
        $this->type = $type;
25 28
        $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