@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @var array |
62 | 62 | */ |
63 | 63 | |
64 | - protected $statics = []; |
|
64 | + protected $statics = []; |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * The dynamic routes have parameters and are stored in a hashtable that every cell have |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | return new Group($group); |
124 | 124 | } |
125 | 125 | |
126 | - public function get ($pattern, $action) { return $this->set("get" , $pattern, $action); } |
|
127 | - public function post ($pattern, $action) { return $this->set("post" , $pattern, $action); } |
|
128 | - public function put ($pattern, $action) { return $this->set("put" , $pattern, $action); } |
|
129 | - public function patch ($pattern, $action) { return $this->set("patch" , $pattern, $action); } |
|
126 | + public function get($pattern, $action) { return $this->set("get", $pattern, $action); } |
|
127 | + public function post($pattern, $action) { return $this->set("post", $pattern, $action); } |
|
128 | + public function put($pattern, $action) { return $this->set("put", $pattern, $action); } |
|
129 | + public function patch($pattern, $action) { return $this->set("patch", $pattern, $action); } |
|
130 | 130 | public function delete($pattern, $action) { return $this->set("delete", $pattern, $action); } |
131 | 131 | |
132 | 132 | /** |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | */ |
32 | 32 | |
33 | 33 | protected $map = [ |
34 | - "index" => ["get", "/{name}"], |
|
35 | - "make" => ["get", "/{name}/make"], |
|
36 | - "create" => ["post", "/{name}"], |
|
37 | - "show" => ["get", "/{name}/{id:int+}"], |
|
38 | - "edit" => ["get", "/{name}/{id:int+}/edit"], |
|
39 | - "update" => ["put", "/{name}/{id:int+}"], |
|
34 | + "index" => ["get", "/{name}"], |
|
35 | + "make" => ["get", "/{name}/make"], |
|
36 | + "create" => ["post", "/{name}"], |
|
37 | + "show" => ["get", "/{name}/{id:int+}"], |
|
38 | + "edit" => ["get", "/{name}/{id:int+}/edit"], |
|
39 | + "update" => ["put", "/{name}/{id:int+}"], |
|
40 | 40 | "delete" => ["delete", "/{name}/{id:int+}"], |
41 | 41 | ]; |
42 | 42 | |
@@ -100,8 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | protected function getResourceActions(array $options) |
102 | 102 | { |
103 | - return isset($options["only"]) ? array_intersect_key($this->map, array_flip((array) $options["only"])) : |
|
104 | - (isset($options["except"]) ? array_diff_key($this->map, array_flip((array) $options["except"])) : $this->map); |
|
103 | + return isset($options["only"]) ? array_intersect_key($this->map, array_flip((array) $options["only"])) : (isset($options["except"]) ? array_diff_key($this->map, array_flip((array) $options["except"])) : $this->map); |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | /** |
@@ -116,8 +115,7 @@ discard block |
||
116 | 115 | protected function getResourcePath($action, $path, $name, array $options) |
117 | 116 | { |
118 | 117 | return str_replace("{name}", $name, |
119 | - $action === "make" && isset($options["translate"]["make"]) ? str_replace("make", $options["translate"]["make"], $path) : |
|
120 | - ($action === "edit" && isset($options["translate"]["edit"]) ? str_replace("edit", $options["translate"]["edit"], $path) : $path)); |
|
118 | + $action === "make" && isset($options["translate"]["make"]) ? str_replace("make", $options["translate"]["make"], $path) : ($action === "edit" && isset($options["translate"]["edit"]) ? str_replace("edit", $options["translate"]["edit"], $path) : $path)); |
|
121 | 119 | } |
122 | 120 | |
123 | 121 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | protected function checkStaticRouteInOtherMethods($targetHttpMethod, $path) |
237 | 237 | { |
238 | - return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) { |
|
238 | + return array_filter($this->getHttpMethodsBut($targetHttpMethod), function($httpMethod) use ($path) { |
|
239 | 239 | return (bool) $this->collector->findStaticRoute($httpMethod, $path); |
240 | 240 | }); |
241 | 241 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | protected function checkDynamicRouteInOtherMethods($targetHttpMethod, $path) |
253 | 253 | { |
254 | - return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) { |
|
254 | + return array_filter($this->getHttpMethodsBut($targetHttpMethod), function($httpMethod) use ($path) { |
|
255 | 255 | return (bool) $this->matchDynamicRoute($httpMethod, $path); |
256 | 256 | }); |
257 | 257 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | private function parseCallableController($controller) |
205 | 205 | { |
206 | - $controller = rtrim($this->namespace, "\\") . "\\" . $this->parseCallablePlaceholders($controller); |
|
206 | + $controller = rtrim($this->namespace, "\\") . "\\" . $this->parseCallablePlaceholders($controller); |
|
207 | 207 | |
208 | 208 | if ($this->controllerCreationFunction === null) { |
209 | 209 | return new $controller; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } |
249 | 249 | |
250 | 250 | $strategy = get_class($this->strategy); |
251 | - throw new BadRouteException("`$strategy` is not a valid route dispatch strategy, ". |
|
251 | + throw new BadRouteException("`$strategy` is not a valid route dispatch strategy, " . |
|
252 | 252 | "it must implement the `Codeburner\\Router\\Strategies\\StrategyInterface` interface."); |
253 | 253 | } |
254 | 254 |