Completed
Push — master ( 0b23f7...de5feb )
by Dave
8s
created

Method   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 39
ccs 16
cts 17
cp 0.9412
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __call() 0 4 1
A getParameters() 0 6 1
B getReturnType() 0 17 6
1
<?php
2
/**
3
 * Mockery
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.txt.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://github.com/padraic/mockery/blob/master/LICENSE
11
 * If you did not receive a copy of the license and are unable to
12
 * obtain it through the world-wide-web, please send an email
13
 * to [email protected] so we can send you a copy immediately.
14
 *
15
 * @category   Mockery
16
 * @package    Mockery
17
 * @copyright  Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com)
18
 * @license    http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
19
 */
20
21
namespace Mockery\Generator;
22
23
class Method
24
{
25
    private $method;
26
27 152
    public function __construct(\ReflectionMethod $method)
28
    {
29 152
        $this->method = $method;
30 152
    }
31
32 152
    public function __call($method, $args)
33
    {
34 152
        return call_user_func_array(array($this->method, $method), $args);
35
    }
36
37
    public function getParameters()
38
    {
39 137
        return array_map(function ($parameter) {
40 65
            return new Parameter($parameter);
41 137
        }, $this->method->getParameters());
42
    }
43
44 137
    public function getReturnType()
45
    {
46 137
        if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0 && $this->method->hasReturnType()) {
47 18
            $returnType = (string) $this->method->getReturnType();
48
49 18
            if ('self' === $returnType) {
50 10
                $returnType = "\\".$this->method->getDeclaringClass()->getName();
0 ignored issues
show
introduced by
Consider using $this->method->class. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
51
            }
52
53 18
            if (version_compare(PHP_VERSION, '7.1.0-dev') >= 0 && $this->method->getReturnType()->allowsNull()) {
54
                $returnType = '?'.$returnType;
55
            }
56
57 18
            return $returnType;
58
        }
59 130
        return '';
60
    }
61
}
62