@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace HnrAzevedo\Router; |
4 | 4 | |
5 | -trait Helper{ |
|
5 | +trait Helper { |
|
6 | 6 | use CheckTrait, ControllerTrait; |
7 | 7 | |
8 | 8 | protected function getProtocol(): string |
9 | 9 | { |
10 | - return (array_key_exists('HTTP_REQUESTED_METHOD',$_SERVER)) ? $_SERVER['HTTP_REQUESTED_METHOD'] : 'get'; |
|
10 | + return (array_key_exists('HTTP_REQUESTED_METHOD', $_SERVER)) ? $_SERVER['HTTP_REQUESTED_METHOD'] : 'get'; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | protected function getData(): ?array |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | protected function import(string $path) |
24 | 24 | { |
25 | 25 | foreach (scandir($path) as $routeFile) { |
26 | - if(pathinfo($path.DIRECTORY_SEPARATOR.$routeFile, PATHINFO_EXTENSION) === 'php'){ |
|
27 | - require_once($path. DIRECTORY_SEPARATOR .$routeFile); |
|
26 | + if (pathinfo($path.DIRECTORY_SEPARATOR.$routeFile, PATHINFO_EXTENSION) === 'php') { |
|
27 | + require_once($path.DIRECTORY_SEPARATOR.$routeFile); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | - protected function ControllerForm($controller, string $method, array $values){ |
|
32 | + protected function ControllerForm($controller, string $method, array $values) { |
|
33 | 33 | $this->check_role(); |
34 | 34 | $role = ($method !== 'method') ? $method : $this->getData()['POST']['role']; |
35 | 35 | $data = (!is_null($values)) ? json_decode($values['data']) : null; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $data = $this->getData(); |
42 | 42 | |
43 | 43 | foreach ($data['GET'] as $name => $value) { |
44 | - $controll = str_replace('{'.$name.'}',$value,$controll); |
|
44 | + $controll = str_replace('{'.$name.'}', $value, $controll); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $this->check_controllsettable($controll); |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | |
51 | 51 | $this->check_controllmethod($controll); |
52 | 52 | |
53 | - $controller = ROUTER_CONFIG['controller.namespace'].'\\'. ucfirst(explode(':',$controll)[0]); |
|
53 | + $controller = ROUTER_CONFIG['controller.namespace'].'\\'.ucfirst(explode(':', $controll)[0]); |
|
54 | 54 | $controller = new $controller(); |
55 | - $method = explode(':',$controll)[1]; |
|
55 | + $method = explode(':', $controll)[1]; |
|
56 | 56 | |
57 | - if( ( $this->getProtocol() == 'form') ){ |
|
57 | + if (($this->getProtocol() == 'form')) { |
|
58 | 58 | $this->ControllerForm($controller, $method, $data['POST']); |
59 | 59 | }else { |
60 | 60 | $controller->$method($data); |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | |
64 | 64 | protected function explodeRoute(bool $bar, string $url): array |
65 | 65 | { |
66 | - return explode( '/', $bar ? substr($url, 0, -1) : $url ); |
|
66 | + return explode('/', $bar ? substr($url, 0, -1) : $url); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | protected function toHiking($walking) |
70 | 70 | { |
71 | - if(is_string($walking)){ |
|
71 | + if (is_string($walking)) { |
|
72 | 72 | $this->Controller($walking); |
73 | 73 | return true; |
74 | 74 | } |