Completed
Push — master ( c00c2f...af7e7e )
by Dave
8s
created

Method::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Mockery\Generator;
4
5
class Method
6
{
7
    private $method;
8
9 128
    public function __construct(\ReflectionMethod $method)
10
    {
11 128
        $this->method = $method;
12 128
    }
13
14 128
    public function __call($method, $args)
15
    {
16 128
        return call_user_func_array(array($this->method, $method), $args);
17
    }
18
19
    public function getParameters()
20
    {
21 111
        return array_map(function ($parameter) {
22 54
            return new Parameter($parameter);
23 111
        }, $this->method->getParameters());
24
    }
25
26 106
    public function getReturnType()
27
    {
28 106
        if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0 && $this->method->hasReturnType()) {
29
            $returnType = (string) $this->method->getReturnType();
30
31
            if ('self' === $returnType) {
32
                return "\\".$this->method->getDeclaringClass()->getName();
33
            }
34
35
            return $returnType;
36
        }
37 106
        return '';
38
    }
39
}
40