Passed
Push — variadic-params-visibility-con... ( ca0a66 )
by Luis
13:54
created

Parameter::__toString()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 7.2
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\Variables\HasType;
11
use PhUml\Code\Variables\Variable;
12
use PhUml\Code\Variables\WithVariable;
13
14
final class Parameter implements HasType
15
{
16
    use WithVariable;
17
18
    /** @var bool */
19
    private $isVariadic;
20
21
    /** @var bool */
22
    private $isByReference;
23
24
    public function __construct(Variable $variable, bool $isVariadic = false, bool $isByReference = false)
25
    {
26
        $this->variable = $variable;
27
        $this->isVariadic = $isVariadic;
28
        $this->isByReference = $isByReference;
29
    }
30
31
    public function __toString(): string
32
    {
33
        return sprintf(
34
            '%s%s%s',
35
            $this->isVariadic ? '...' : '',
36
            $this->isByReference ? '&' : '',
37
            $this->variable
38
        );
39
    }
40
}
41