| @@ 70-84 (lines=15) @@ | ||
| 67 | return $result; |
|
| 68 | } |
|
| 69 | ||
| 70 | public function add(string $method, string $route, $permission, callable $callable) |
|
| 71 | { |
|
| 72 | $entry = (object)[ |
|
| 73 | 'route' => $route, |
|
| 74 | 'pattern' => $this->createPattern($route), |
|
| 75 | 'permission' => $permission, |
|
| 76 | 'callable' => $callable |
|
| 77 | ]; |
|
| 78 | ||
| 79 | if (!array_key_exists($method, $this->routes)) { |
|
| 80 | $this->routes[$method] = []; |
|
| 81 | } |
|
| 82 | ||
| 83 | $this->routes[$method][] = $entry; |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Creates a regex-enabled pattern from the route |
|
| @@ 179-194 (lines=16) @@ | ||
| 176 | * @param string $route |
|
| 177 | * @param callable $callable |
|
| 178 | */ |
|
| 179 | private function add(string $method, string $route, callable $callable) |
|
| 180 | { |
|
| 181 | $pattern = $this->createPattern($route); |
|
| 182 | ||
| 183 | $entry = (object)[ |
|
| 184 | 'route' => $route, |
|
| 185 | 'pattern' => $pattern, |
|
| 186 | 'callable' => $callable |
|
| 187 | ]; |
|
| 188 | ||
| 189 | if (!array_key_exists($method, $this->routes)) { |
|
| 190 | $this->routes[$method] = []; |
|
| 191 | } |
|
| 192 | ||
| 193 | $this->routes[$method][$pattern] = $entry; |
|
| 194 | } |
|
| 195 | ||
| 196 | /** |
|
| 197 | * Creates a regex-enabled pattern from the route |
|