Client   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Test Coverage

Coverage 96.43%

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 112
ccs 27
cts 28
cp 0.9643
rs 10
c 0
b 0
f 0
wmc 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setUri() 0 3 1
A __construct() 0 6 1
A getArgs() 0 3 1
A getArg() 0 3 1
A getMethod() 0 3 1
A getName() 0 3 1
A getCallback() 0 3 1
A setArg() 0 3 1
A getUri() 0 11 2
1
<?php
2
3
namespace Bonfim\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 18
    public function __construct(array $route)
42
    {
43 18
        $this->uri = $route['uri'];
44 18
        $this->name = $route['name'];
45 18
        $this->method = $route['method'];
46 18
        $this->callback = $route['callback'];
47 18
    }
48
49
    /**
50
     * @return array
51
     */
52 3
    public function getUri(): array
53
    {
54 3
        $uri = explode('/', $this->uri);
55 3
        $uri = array_filter($uri);
56 3
        $uri = array_values($uri);
57
58 3
        if (count($uri) == 0) {
59
            return ['index'];
60
        }
61
62 3
        return $uri;
63
    }
64
65
    /**
66
     * @return string
67
     */
68 3
    public function getName(): string
69
    {
70 3
        return $this->name;
71
    }
72
73
    /**
74
     * @return string
75
     */
76 3
    public function getMethod(): string
77
    {
78 3
        return $this->method;
79
    }
80
81
    /**
82
     * @return mixed
83
     */
84 3
    public function getCallback()
85
    {
86 3
        return $this->callback;
87
    }
88
89
    /**
90
     * @return array|mixed
91
     */
92 3
    public function getArgs(): array
93
    {
94 3
        return $this->args;
95
    }
96
97
    /**
98
     * @param $key
99
     * @return mixed
100
     */
101 3
    public function getArg($key)
102
    {
103 3
        return $this->args[$key];
104
    }
105
106
    /**
107
     * @param string $key
108
     * @param string $value
109
     */
110 18
    public function setArg(string $key, string $value): void
111
    {
112 18
        $this->args[$key] = $value;
113 18
    }
114
115
    /**
116
     * @param string $uri
117
     */
118 18
    public function setUri(string $uri): void
119
    {
120 18
        $this->uri = $uri;
121 18
    }
122
}
123