Test Failed
Push — master ( c0baca...92e477 )
by Bohuslav
10:33
created

ParsedRoute::__call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Kambo\Router\Route;
4
5
/**
6
 * Parsed route from matcher class.
7
 * Class is implemented as a proxy for existing Route object.
8
 *
9
 * @author  Bohuslav Simek <[email protected]>
10
 * @license Apache-2.0
11
 * @package Kambo\Router\Route
12
 */
13
class ParsedRoute
14
{
15
    /**
16
     * Instance of original route
17
     *
18
     * @var \Kambo\Router\Route
19
     */
20
    private $route;
21
22
    /**
23
     * Route placeholders from route.
24
     *
25
     * @var array
26
     */
27
    private $placeholders;
28
29
    /**
30
     * Route parameters from request
31
     *
32
     * @var array
33
     */
34
    private $parameters;
35
36
    /**
37
     * ParsedRoute constructor
38
     *
39
     * @param \Kambo\Router\Route $route
40
     */
41 18
    public function __construct(/*Route*/ $route)
42
    {
43 18
        $this->route = $route;
44 18
    }
45
46
    /**
47
     * Magic method for proxing methods call to parent object.
48
     *
49
     * @param string $name      Method name
50
     * @param array  $arguments The parameters to be passed to the method,
51 16
     *                          as an indexed array.
52
     */
53 16
    public function __call($name, array $arguments)
54
    {
55
        return call_user_func_array([$this->route, $name], $arguments);
56
    }
57
58
    /**
59
     * Get route method
60
     *
61 16
     * @return string
62
     */
63 16
    public function getMethod()
64
    {
65
        return $this->route->getMethod();
66
    }
67
68
    /**
69
     * Get handler
70
     *
71
     * @return mixed
72
     */
73 18
    public function getHandler()
74
    {
75 18
        return $this->route->getHandler();
76
    }
77 18
78
    /**
79
     * Sets placeholders extracted from route.
80
     *
81
     * @param mixed $parameters
0 ignored issues
show
Bug introduced by
There is no parameter named $parameters. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
82
     *
83
     * @return self for fluent interface
84
     */
85 15
    public function setPlaceholders($placeholders)
86
    {
87 15
        $this->placeholders = $placeholders;
88
89
        return $this;
90
    }
91
92
    /**
93
     * Get placeholders extracted from route.
94
     *
95
     * @return array
96
     */
97 16
    public function getPlaceholders()
98
    {
99 16
        return $this->placeholders;
100
    }
101 16
102
    /**
103
     * Sets parameters for route from request.
104
     *
105
     * @param mixed $parameters
106
     *
107
     * @return self for fluent interface
108
     */
109 15
    public function setParameters($parameters)
110
    {
111 15
        $this->parameters = $parameters;
0 ignored issues
show
Documentation Bug introduced by
It seems like $parameters of type * is incompatible with the declared type array of property $parameters.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
112
113
        return $this;
114
    }
115
116
    /**
117
     * Get parameters of route from request.
118
     *
119
     * @return array
120
     */
121
    public function getParameters()
122
    {
123
        return $this->parameters;
124
    }
125
}
126