Test Failed
Branch develop (ab83c3)
by Bohuslav
02:47
created

Parsed   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 113
c 0
b 0
f 0
wmc 8
lcom 1
cbo 1
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __call() 0 4 1
A getMethod() 0 4 1
A getHandler() 0 4 1
A setPlaceholders() 0 6 1
A getPlaceholders() 0 4 1
A setParameters() 0 6 1
A getParameters() 0 4 1
1
<?php
2
namespace Kambo\Router\Route\Route;
3
4
use Kambo\Router\Route\Route;
5
6
/**
7
 * Parsed route from matcher class.
8
 * Class is implemented as a proxy for existing Route object.
9
 *
10
 * @package Kambo\Router\Route\Route
11
 * @author  Bohuslav Simek <[email protected]>
12
 * @license MIT
13
 */
14
class Parsed
15
{
16
    /**
17
     * Instance of original route
18
     *
19
     * @var \Kambo\Router\Route\Route
20
     */
21
    private $route;
22
23
    /**
24
     * Route placeholders from route.
25
     *
26
     * @var array
27
     */
28
    private $placeholders;
29
30
    /**
31
     * Route parameters from request
32
     *
33
     * @var array
34
     */
35
    private $parameters;
36
37
    /**
38
     * ParsedRoute constructor
39
     *
40
     * @param \Kambo\Router\Route\Route $route
41
     */
42
    public function __construct(/*Route*/ $route)
43
    {
44
        $this->route = $route;
45
    }
46
47
    /**
48
     * Magic method for proxing methods call to parent object.
49
     *
50
     * @param string $name      Method name
51
     * @param array  $arguments The parameters to be passed to the method,
52
     *                          as an indexed array.
53
     */
54
    public function __call($name, array $arguments)
55
    {
56
        return call_user_func_array([$this->route, $name], $arguments);
57
    }
58
59
    /**
60
     * Get route method
61
     *
62
     * @return string
63
     */
64
    public function getMethod()
65
    {
66
        return $this->route->getMethod();
67
    }
68
69
    /**
70
     * Get handler
71
     *
72
     * @return mixed
73
     */
74
    public function getHandler()
75
    {
76
        return $this->route->getHandler();
77
    }
78
79
    /**
80
     * Sets placeholders extracted from route.
81
     *
82
     * @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...
83
     *
84
     * @return self for fluent interface
85
     */
86
    public function setPlaceholders($placeholders)
87
    {
88
        $this->placeholders = $placeholders;
89
90
        return $this;
91
    }
92
93
    /**
94
     * Get placeholders extracted from route.
95
     *
96
     * @return array
97
     */
98
    public function getPlaceholders()
99
    {
100
        return $this->placeholders;
101
    }
102
103
    /**
104
     * Sets parameters for route from request.
105
     *
106
     * @param mixed $parameters
107
     *
108
     * @return self for fluent interface
109
     */
110
    public function setParameters($parameters)
111
    {
112
        $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...
113
114
        return $this;
115
    }
116
117
    /**
118
     * Get parameters of route from request.
119
     *
120
     * @return array
121
     */
122
    public function getParameters()
123
    {
124
        return $this->parameters;
125
    }
126
}
127