Completed
Push — master ( 0b6473...8155cd )
by Edson
01:55
created

BaseRoute::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Router;
4
5
/**
6
 * Class BaseRoute
7
 * @package Router
8
 */
9
class BaseRoute
10
{
11
    /**
12
     * @var mixed
13
     */
14
    private $uri;
15
16
    /**
17
     * @var mixed
18
     */
19
    private $name;
20
21
    /**
22
     * @var mixed
23
     */
24
25
    private $method;
26
    /**
27
     * @var mixed
28
     */
29
30
    private $callback;
31
32
    /**
33
     * @var array
34
     */
35
    private $args = [];
36
37
    /**
38
     * BaseRoute constructor.
39
     * @param array $route
40
     */
41
    public function __construct(array $route)
42
    {
43
        $this->uri = $route['uri'];
44
        $this->name = $route['name'];
45
        $this->method = $route['method'];
46
        $this->callback = $route['callback'];
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getUri(): string
53
    {
54
        return $this->uri;
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function getName(): string
61
    {
62
        return $this->name;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getMethod(): string
69
    {
70
        return $this->method;
71
    }
72
73
    /**
74
     * @return mixed
75
     */
76
    public function getCallback()
77
    {
78
        return $this->callback;
79
    }
80
81
    /**
82
     * @return array|mixed
83
     */
84
    public function getArgs(): array
85
    {
86
        return $this->args;
87
    }
88
89
    /**
90
     * @param $key
91
     * @return mixed
92
     */
93
    public function getArg($key)
94
    {
95
        return $this->args[$key];
96
    }
97
98
    /**
99
     * @param string $uri
100
     */
101
    public function setUri(string $uri): void
102
    {
103
        $this->uri = $uri;
104
    }
105
106
    /**
107
     * @param string $key
108
     * @param string $value
109
     */
110
    public function setArg(string $key, string $value): void
111
    {
112
        $this->args[$key] = $value;
113
    }
114
}
115