Passed
Push — master ( 1416ae...b5a8b1 )
by Luis
54s queued 13s
created

Parameter   A

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 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 5
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Code\Parameters;
9
10
use PhUml\Code\Name;
11
use PhUml\Code\Variables\HasType;
12
use PhUml\Code\Variables\Variable;
13
use PhUml\Code\Variables\WithVariable;
14
use Stringable;
15
16
final class Parameter implements HasType, Stringable
17
{
18
    use WithVariable;
19
20 40
    public function __construct(
21
        Variable $variable,
22
        private readonly bool $isVariadic = false,
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 22 at column 25
Loading history...
23
        private readonly bool $isByReference = false
24
    ) {
25 40
        $this->variable = $variable;
26
    }
27
28
    /** @return Name[] */
29 14
    public function references(): array
30
    {
31 14
        return $this->variable->references();
32
    }
33
34 16
    public function __toString(): string
35
    {
36 16
        return sprintf(
37
            '%s%s%s',
38 16
            $this->isVariadic ? '...' : '',
39 16
            $this->isByReference ? '&' : '',
40 16
            $this->variable
41
        );
42
    }
43
}
44