Completed
Push — master ( 91edc0...9fe488 )
by Edson
11s
created

Client::getMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Router;
4
5
/**
6
 * Class Client
7
 * @package Router
8
 */
9
class Client
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
     * Client 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 array
51
     */
52
    public function getUri(): array
53
    {
54
        $uri = explode('/', $this->uri);
55
        $uri = array_filter($uri);
56
        $uri = array_values($uri);
57
58
        if (count($uri) == 0) {
59
            return ['index'];
60
        }
61
62
        return $uri;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getName(): string
69
    {
70
        return $this->name;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getMethod(): string
77
    {
78
        return $this->method;
79
    }
80
81
    /**
82
     * @return mixed
83
     */
84
    public function getCallback()
85
    {
86
        return $this->callback;
87
    }
88
89
    /**
90
     * @return array|mixed
91
     */
92
    public function getArgs(): array
93
    {
94
        return $this->args;
95
    }
96
97
    /**
98
     * @param $key
99
     * @return mixed
100
     */
101
    public function getArg($key)
102
    {
103
        return $this->args[$key];
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
    /**
116
     * @param string $uri
117
     */
118
    public function setUri(string $uri): void
119
    {
120
        $this->uri = $uri;
121
    }
122
}
123