Completed
Push — master ( 3f1b14...d7a449 )
by Luis
14:49 queued 04:53
created

Method   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isConstructor() 0 3 1
A __toString() 0 7 2
A __construct() 0 5 1
1
<?php
2
/**
3
 * PHP version 7.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;
9
10
class Method
11
{
12
    private static $symbols = [
13
        'private' => '-',
14
        'protected' => '#',
15
        'public' => '+',
16
    ];
17
18
    /** @var string */
19
    public $name;
20
21
    /** @var string */
22
    public $modifier;
23
24
    /** @var Variable[] */
25
    public $params;
26
27
    public function __construct(string $name, string $modifier = 'public', array $params = [])
28
    {
29
        $this->name = $name;
30
        $this->modifier = $modifier;
31
        $this->params = $params;
32
    }
33
34
    public function isConstructor(): bool
35
    {
36
        return $this->name === '__construct';
37
    }
38
39
    public function __toString()
40
    {
41
        return sprintf(
42
            '%s%s%s',
43
            self::$symbols[$this->modifier],
44
            $this->name,
45
            empty($this->params) ? '()' : '( ' . implode($this->params, ', ') . ' )'
0 ignored issues
show
Bug introduced by
$this->params of type PhUml\Code\Variable[] 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

45
            empty($this->params) ? '()' : '( ' . implode(/** @scrutinizer ignore-type */ $this->params, ', ') . ' )'
Loading history...
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

45
            empty($this->params) ? '()' : '( ' . implode($this->params, /** @scrutinizer ignore-type */ ', ') . ' )'
Loading history...
46
        );
47
    }
48
}
49