Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
CRAP | |
100.00% |
1 / 1 |
| AddsRoutes | |
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
|
100.00% |
9 / 9 |
9 | |
100.00% |
1 / 1 |
| addRoute | n/a |
0 / 0 |
n/a |
0 / 0 |
n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||||
| any | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| map | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| post | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| put | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| patch | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| delete | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| head | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| options | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Router; |
| 6 | |
| 7 | /** @psalm-require-implements RouteAdder */ |
| 8 | trait AddsRoutes |
| 9 | { |
| 10 | abstract public function addRoute(Route $route): Route; |
| 11 | |
| 12 | /** @param callable|list{string, string}|non-empty-string $view */ |
| 13 | public function any(string $pattern, callable|array|string $view, string $name = ''): Route |
| 14 | { |
| 15 | return $this->addRoute(Route::any($pattern, $view, $name)); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * @param array<array-key, string> $methods |
| 20 | * @param callable|list{string, string}|non-empty-string $view |
| 21 | */ |
| 22 | public function map( |
| 23 | array $methods, |
| 24 | string $pattern, |
| 25 | callable|array|string $view, |
| 26 | string $name = '', |
| 27 | ): Route { |
| 28 | return $this->addRoute(Route::map($methods, $pattern, $view, $name)); |
| 29 | } |
| 30 | |
| 31 | /** @param callable|list{string, string}|non-empty-string $view */ |
| 32 | public function get(string $pattern, callable|array|string $view, string $name = ''): Route |
| 33 | { |
| 34 | return $this->addRoute(Route::get($pattern, $view, $name)); |
| 35 | } |
| 36 | |
| 37 | /** @param callable|list{string, string}|non-empty-string $view */ |
| 38 | public function post(string $pattern, callable|array|string $view, string $name = ''): Route |
| 39 | { |
| 40 | return $this->addRoute(Route::post($pattern, $view, $name)); |
| 41 | } |
| 42 | |
| 43 | /** @param callable|list{string, string}|non-empty-string $view */ |
| 44 | public function put(string $pattern, callable|array|string $view, string $name = ''): Route |
| 45 | { |
| 46 | return $this->addRoute(Route::put($pattern, $view, $name)); |
| 47 | } |
| 48 | |
| 49 | /** @param callable|list{string, string}|non-empty-string $view */ |
| 50 | public function patch(string $pattern, callable|array|string $view, string $name = ''): Route |
| 51 | { |
| 52 | return $this->addRoute(Route::patch($pattern, $view, $name)); |
| 53 | } |
| 54 | |
| 55 | /** @param callable|list{string, string}|non-empty-string $view */ |
| 56 | public function delete(string $pattern, callable|array|string $view, string $name = ''): Route |
| 57 | { |
| 58 | return $this->addRoute(Route::delete($pattern, $view, $name)); |
| 59 | } |
| 60 | |
| 61 | /** @param callable|list{string, string}|non-empty-string $view */ |
| 62 | public function head(string $pattern, callable|array|string $view, string $name = ''): Route |
| 63 | { |
| 64 | return $this->addRoute(Route::head($pattern, $view, $name)); |
| 65 | } |
| 66 | |
| 67 | /** @param callable|list{string, string}|non-empty-string $view */ |
| 68 | public function options(string $pattern, callable|array|string $view, string $name = ''): Route |
| 69 | { |
| 70 | return $this->addRoute(Route::options($pattern, $view, $name)); |
| 71 | } |
| 72 | } |