@@ -12,8 +12,8 @@ |
||
12 | 12 | private array $methods, |
13 | 13 | private string $name, |
14 | 14 | private ?array $where, |
15 | - private ?string|?\Closure $after, |
|
16 | - private ?string|?\Closure $before, |
|
15 | + private ?string | ?\Closure $after, |
|
16 | + private ?string | ?\Closure $before, |
|
17 | 17 | private ?array $attributes, |
18 | 18 | private ?array $middleware |
19 | 19 | ) {} |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace HnrAzevedo\Router; |
6 | 6 | |
@@ -29,23 +29,23 @@ discard block |
||
29 | 29 | |
30 | 30 | public static function loadPipeline(): void |
31 | 31 | { |
32 | - foreach(self::getInstance()->getPipeline() as $line){ |
|
32 | + foreach (self::getInstance()->getPipeline() as $line) { |
|
33 | 33 | self::getInstance()->loadLine(new ReflectionObject(new $line())); |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | 37 | private function loadLine(ReflectionObject $reflection): void |
38 | 38 | { |
39 | - foreach($reflection->getMethods() as $method){ |
|
39 | + foreach ($reflection->getMethods() as $method) { |
|
40 | 40 | $this->loadMethod($method); |
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | 44 | private function loadMethod(ReflectionMethod $method): void |
45 | 45 | { |
46 | - try{ |
|
46 | + try { |
|
47 | 47 | foreach ($method->getAttributes() as $attr) { |
48 | - if($attr->getName() != 'HnrAzevedo\Router\RouteAttribute') continue; |
|
48 | + if ($attr->getName() != 'HnrAzevedo\Router\RouteAttribute') continue; |
|
49 | 49 | |
50 | 50 | $args = $attr->getArguments(); |
51 | 51 | |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | ->attrWhere($args) |
65 | 65 | ->attrMiddleware($args); |
66 | 66 | } |
67 | - }catch(Exception $er){ |
|
67 | + }catch (Exception $er) { |
|
68 | 68 | throw new Exception('Failed to add route via attribute: '.$er->getMessage()); |
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | 72 | private function checkArgs(array $args): self |
73 | 73 | { |
74 | - if(!array_key_exists('uri', $args) || !array_key_exists('methods', $args)) { |
|
74 | + if (!array_key_exists('uri', $args) || !array_key_exists('methods', $args)) { |
|
75 | 75 | throw new Exception('Misconfigured route attribute'); |
76 | 76 | } |
77 | 77 | return $this; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | private function attrName(array $attr): self |
81 | 81 | { |
82 | - if(array_key_exists('name', $attr)) { |
|
82 | + if (array_key_exists('name', $attr)) { |
|
83 | 83 | self::getInstance()->name($attr['name']); |
84 | 84 | } |
85 | 85 | return $this; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | private function attrBefore(array $attr): self |
89 | 89 | { |
90 | - if(array_key_exists('before', $attr)) { |
|
90 | + if (array_key_exists('before', $attr)) { |
|
91 | 91 | self::getInstance()->before($attr['before']); |
92 | 92 | } |
93 | 93 | return $this; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | private function attrAfter(array $attr): self |
97 | 97 | { |
98 | - if(array_key_exists('after', $attr)) { |
|
98 | + if (array_key_exists('after', $attr)) { |
|
99 | 99 | self::getInstance()->after($attr['after']); |
100 | 100 | } |
101 | 101 | return $this; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | |
104 | 104 | private function attrAttributes(array $attr): self |
105 | 105 | { |
106 | - if(array_key_exists('attributes', $attr)) { |
|
107 | - foreach($attr['attributes'] as $attribute){ |
|
106 | + if (array_key_exists('attributes', $attr)) { |
|
107 | + foreach ($attr['attributes'] as $attribute) { |
|
108 | 108 | self::getInstance()->attribute($attribute[0], $attribute[1]); |
109 | 109 | } |
110 | 110 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | private function attrWhere(array $attr): self |
115 | 115 | { |
116 | - if(array_key_exists('where', $attr)) { |
|
116 | + if (array_key_exists('where', $attr)) { |
|
117 | 117 | self::getInstance()->where($attr['where']); |
118 | 118 | } |
119 | 119 | return $this; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | private function attrMiddleware(array $attr): self |
123 | 123 | { |
124 | - if(array_key_exists('middleware', $attr)) { |
|
124 | + if (array_key_exists('middleware', $attr)) { |
|
125 | 125 | self::getInstance()->middleware($attr['middleware']); |
126 | 126 | } |
127 | 127 | return $this; |