Parameter::references()   A
last analyzed

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\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