Completed
Push — master ( ed922a...ce73d9 )
by Nikola
03:26
created

MethodChoice::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace RunOpenCode\AbstractBuilder\Command;
4
5
use RunOpenCode\AbstractBuilder\Ast\MethodMetadata;
6
use RunOpenCode\AbstractBuilder\Ast\ParameterMetadata;
7
8
class MethodChoice
9
{
10
    private $method;
11
12
    public function __construct(MethodMetadata $method)
13
    {
14
        $this->method = $method;
15
    }
16
17
    public function getMethod()
18
    {
19
        return $this->method;
20
    }
21
22
    public function __toString()
23
    {
24
        $parameters = [];
25
26
        /**
27
         * @var ParameterMetadata $parameter
28
         */
29
        foreach ($this->method->getParameters() as $parameter) {
30
            $parameters[] =(($parameter->getType()) ? $parameter->getType().' ' : '').'$'.$parameter->getName();
31
        }
32
33
        return sprintf('%s(%s)%s', $this->method->getName(), implode(', ', $parameters), ($this->method->getReturnType()) ? ' :'.$this->method->getReturnType() : '');
34
    }
35
}
36