Test Failed
Push — master ( 13b119...3f1b14 )
by Luis
04:05 queued 01:41
created

plPhpFunction::__toString()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 1
nop 0
1
<?php
2
3
class plPhpFunction
4
{
5
    private static $symbols = [
6
        'private' => '-',
7
        'protected' => '#',
8
        'public' => '+',
9
    ];
10
11
    /** @var string */
12
    public $name;
13
14
    /** @var string */
15
    public $modifier;
16
17
    /** @var plPhpVariable[] */
18
    public $params;
19
20
    public function __construct(string $name, string $modifier = 'public', array $params = [])
21
    {
22
        $this->name = $name;
23
        $this->modifier = $modifier;
24
        $this->params = $params;
25
    }
26
27
    public function isConstructor(): bool
28
    {
29
        return $this->name === '__construct';
30
    }
31
32
    public function __toString()
33
    {
34
        return sprintf(
35
            '%s%s%s',
36
            self::$symbols[$this->modifier],
37
            $this->name,
38
            empty($this->params) ? '()' : '( ' . implode($this->params, ', ') . ' )'
0 ignored issues
show
Bug introduced by
', ' of type string is incompatible with the type array expected by parameter $pieces of implode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
            empty($this->params) ? '()' : '( ' . implode($this->params, /** @scrutinizer ignore-type */ ', ') . ' )'
Loading history...
Bug introduced by
$this->params of type plPhpVariable[] is incompatible with the type string expected by parameter $glue of implode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
            empty($this->params) ? '()' : '( ' . implode(/** @scrutinizer ignore-type */ $this->params, ', ') . ' )'
Loading history...
39
        );
40
    }
41
}
42