MethodRow::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4286
cc 2
eloc 6
nc 2
nop 3
1
<?php
2
3
namespace Saxulum\PhpDocGenerator;
4
5
class MethodRow extends AbstractRow
6
{
7
    /**
8
     * @param string               $name
9
     * @param string|null          $returnType
10
     * @param MethodRowParameter[] $parameters
11
     */
12
    public function __construct($name, $returnType = null, array $parameters = array())
13
    {
14
        $this->addPart($returnType);
15
16
        if (count($parameters) === 0) {
17
            $this->addPart($name, null, '()');
18
        } else {
19
            $this->addPart($name, null, '('.$this->handleParameters($parameters).')');
20
        }
21
    }
22
23
    /**
24
     * @param  array  $parameters
25
     * @return string
26
     */
27
    protected function handleParameters($parameters = array())
28
    {
29
        $parameterString = '';
30
        foreach ($parameters as $parameter) {
31
            $parameterString .= (string) $parameter.', ';
32
        }
33
34
        return substr($parameterString, 0, -2);
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getName()
41
    {
42
        return 'method';
43
    }
44
}
45