Completed
Push — master ( b9be26...c0baca )
by Bohuslav
02:07
created

ParsedRoute::__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

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
 * @package Kambo\Router\Route
10
 * @author  Bohuslav Simek <[email protected]>
11
 * @license MIT
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;
0 ignored issues
show
Documentation Bug introduced by
It seems like $route of type object<Kambo\Router\Route\Route> is incompatible with the declared type object<Kambo\Router\Route> of property $route.

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...
44 18
    }
45
46
    /**
47
     * Get route method
48
     *
49
     * @return string
50
     */
51 16
    public function getMethod()
52
    {
53 16
        return $this->route->getMethod();
54
    }
55
56
    /**
57
     * Get handler
58
     *
59
     * @return mixed
60
     */
61 16
    public function getHandler()
62
    {
63 16
        return $this->route->getHandler();
64
    }
65
66
    /**
67
     * Sets placeholders extracted from route.
68
     *
69
     * @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...
70
     *
71
     * @return self for fluent interface
72
     */
73 18
    public function setPlaceholders($placeholders)
74
    {
75 18
        $this->placeholders = $placeholders;
76
77 18
        return $this;
78
    }
79
80
    /**
81
     * Get placeholders extracted from route.
82
     *
83
     * @return array
84
     */
85 15
    public function getPlaceholders()
86
    {
87 15
        return $this->placeholders;
88
    }
89
90
    /**
91
     * Sets parameters for route from request.
92
     *
93
     * @param mixed $parameters
94
     *
95
     * @return self for fluent interface
96
     */
97 16
    public function setParameters($parameters)
98
    {
99 16
        $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...
100
101 16
        return $this;
102
    }
103
104
    /**
105
     * Get parameters of route from request.
106
     *
107
     * @return array
108
     */
109 15
    public function getParameters()
110
    {
111 15
        return $this->parameters;
112
    }
113
}
114