Passed
Pull Request — master (#22)
by Luis
24:40 queued 21:48
created

Parameter::__toString()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
nc 1
nop 0
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 3
rs 10
c 1
b 0
f 0
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