RouteContainer::getParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Psecio\Invoke;
4
5
class RouteContainer
6
{
7
    /**
8
     * Current route (match) instance
9
     * @var \Psecio\Invoke\MatchInstance
10
     */
11
    private $route;
12
13
    /**
14
     * Current configuration
15
     * @var array
16
     */
17
    private $config;
18
19
    /**
20
     * Parameters found in route processing
21
     * @var array
22
     */
23
    private $params = [];
24
25
    /**
26
     * Initialize the container with the provided route and
27
     *     configuration information
28
     *
29
     * @param string $route Route to provide to the match
30
     * @param array $config Route configuration
31
     */
32
    public function __construct($route, array $config)
33
    {
34
        $this->route = \Psecio\Invoke\Match::create('route.regex',
0 ignored issues
show
Documentation Bug introduced by
It seems like \Psecio\Invoke\Match::cr...ray('route' => $route)) of type object<Psecio\Invoke\Match> is incompatible with the declared type object<Psecio\Invoke\MatchInstance> 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...
35
            array('route' => $route));
36
        $this->config = $config;
37
    }
38
39
    /**
40
     * Get the current configuration
41
     *
42
     * @return array Configuration set
43
     */
44 View Code Duplication
    public function getConfig($name = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        if ($name !== null) {
47
            return (isset($this->config[$name])) ? $this->config[$name] : null;
48
        } else {
49
            return $this->config;
50
        }
51
    }
52
53
    /**
54
     * Get the current route instance
55
     *
56
     * @return \Psecio\Invoke\MatchInstance
57
     */
58
    public function getRoute()
59
    {
60
        return $this->route;
61
    }
62
63
    /**
64
     * Set the parameters for the current route match
65
     *
66
     * @param array $params Parameter set
67
     */
68
    public function setParams(array $params = array())
69
    {
70
        $this->params = $params;
71
    }
72
73
    /**
74
     * Get the current parameter set
75
     *
76
     * @return array Parameter set
77
     */
78
    public function getParams()
79
    {
80
        return $this->params;
81
    }
82
}