@@ -4,25 +4,25 @@ discard block |
||
4 | 4 | |
5 | 5 | use Exception; |
6 | 6 | |
7 | -trait CheckWhere{ |
|
7 | +trait CheckWhere { |
|
8 | 8 | |
9 | 9 | protected function checkWhereParam($data) |
10 | 10 | { |
11 | - if(count($data) === 0){ |
|
11 | + if (count($data) === 0) { |
|
12 | 12 | throw new Exception('It is necessary to define a condition to be tested.'); |
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
16 | 16 | protected function checkExistParam($param, $data) |
17 | 17 | { |
18 | - if(!array_key_exists($param,$data)){ |
|
18 | + if (!array_key_exists($param, $data)) { |
|
19 | 19 | throw new Exception('Test parameter not available on the route in question.'); |
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
23 | 23 | protected function checkWhereParams($params) |
24 | 24 | { |
25 | - if(count($params) === 0){ |
|
25 | + if (count($params) === 0) { |
|
26 | 26 | throw new Exception('The route in question has no parameters to be tested.'); |
27 | 27 | } |
28 | 28 | } |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | { |
32 | 32 | $pass = true; |
33 | 33 | |
34 | - if(!is_array($route['where'])){ |
|
34 | + if (!is_array($route['where'])) { |
|
35 | 35 | return $pass; |
36 | 36 | } |
37 | 37 | |
38 | - $routeURI = explode('/',$route['url']); |
|
38 | + $routeURI = explode('/', $route['url']); |
|
39 | 39 | $params = []; |
40 | - foreach($routeURI as $p => $part){ |
|
41 | - if(substr($part,0,1) === '{' && substr($part,-1) === '}'){ |
|
42 | - $param = substr($part,1,-1); |
|
40 | + foreach ($routeURI as $p => $part) { |
|
41 | + if (substr($part, 0, 1) === '{' && substr($part, -1) === '}') { |
|
42 | + $param = substr($part, 1, -1); |
|
43 | 43 | $params[$param] = $route['where'][$param]; |
44 | 44 | |
45 | - if(!preg_match("/^{$params[$param]}$/",$request[$p])){ |
|
45 | + if (!preg_match("/^{$params[$param]}$/", $request[$p])) { |
|
46 | 46 | $pass = false; |
47 | 47 | } |
48 | 48 | } |