Parameter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A references() 0 3 1
A __toString() 0 7 3
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\Parameters;
7
8
use PhUml\Code\Name;
9
use PhUml\Code\Variables\HasType;
10
use PhUml\Code\Variables\Variable;
11
use PhUml\Code\Variables\WithVariable;
12
use Stringable;
13
14
final class Parameter implements HasType, Stringable
15
{
16
    use WithVariable;
17
18 41
    public function __construct(
19
        Variable $variable,
20
        private readonly bool $isVariadic = false,
21
        private readonly bool $isByReference = false
22
    ) {
23 41
        $this->variable = $variable;
0 ignored issues
show
Bug introduced by
The property variable is declared read-only in PhUml\Code\Parameters\Parameter.
Loading history...
24
    }
25
26
    /** @return Name[] */
27 14
    public function references(): array
28
    {
29 14
        return $this->variable->references();
30
    }
31
32 16
    public function __toString(): string
33
    {
34 16
        return sprintf(
35
            '%s%s%s',
36 16
            $this->isVariadic ? '...' : '',
37 16
            $this->isByReference ? '&' : '',
38 16
            $this->variable
39
        );
40
    }
41
}
42