Total Complexity | 9 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Request |
||
11 | { |
||
12 | private $alto_match; |
||
13 | private Response $target; |
||
14 | |||
15 | public function __construct(array $match) |
||
16 | { |
||
17 | $this->alto_match = $match; |
||
18 | $this->target = new Response($this); |
||
19 | } |
||
20 | |||
21 | // DEPRECATED |
||
22 | public function target() |
||
25 | } |
||
26 | |||
27 | public function name() |
||
28 | { |
||
29 | return $this->alto_match['name']; |
||
30 | } |
||
31 | |||
32 | // @return array of all GET params if $name is null |
||
33 | // @return null if $name is not an index |
||
34 | // @return return urldecoded string |
||
35 | public function params($name = null) |
||
36 | { |
||
37 | $params = $this->alto_match['params'] ?? []; |
||
38 | |||
39 | if(is_null($name)){ |
||
40 | return $params; |
||
41 | } |
||
42 | |||
43 | if (!isset($params[$name])) { |
||
44 | return null; |
||
45 | } |
||
46 | |||
47 | if (is_string($params[$name])) { |
||
48 | return urldecode($params[$name]); |
||
49 | } |
||
50 | return $params[$name]; |
||
51 | } |
||
52 | |||
53 | public function submitted($name = null) |
||
60 | } |
||
61 | } |
||
62 |