EndpointRoute   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 47
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A post() 0 4 1
A put() 0 4 1
A delete() 0 4 1
A patch() 0 4 1
A head() 0 4 1
A options() 0 4 1
A anyMethod() 0 4 1
A buildMiddlewareFor() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace hiapi\Core\Http;
5
6
use Closure;
7
use hiapi\Core\Http\Psr15\Middleware\EndpointMiddleware;
8
use Yiisoft\Router\Route;
9
10
class EndpointRoute
11
{
12
    public static function get(string $pattern, string $name): Route
13
    {
14
        return Route::get($pattern)->middleware(static::buildMiddlewareFor($name));
15
    }
16
17
    public static function post(string $pattern, string $name): Route
18
    {
19
        return Route::post($pattern)->middleware(static::buildMiddlewareFor($name));
20
    }
21
22
    public static function put(string $pattern, string $name): Route
23
    {
24
        return Route::put($pattern)->middleware(static::buildMiddlewareFor($name));
25
    }
26
27
    public static function delete(string $pattern, string $name): Route
28
    {
29
        return Route::delete($pattern)->middleware(static::buildMiddlewareFor($name));
30
    }
31
32
    public static function patch(string $pattern, string $name): Route
33
    {
34
        return Route::patch($pattern)->middleware(static::buildMiddlewareFor($name));
35
    }
36
37
    public static function head(string $pattern, string $name): Route
38
    {
39
        return Route::head($pattern)->middleware(static::buildMiddlewareFor($name));
40
    }
41
42
    public static function options(string $pattern, string $name): Route
43
    {
44
        return Route::options($pattern)->middleware(static::buildMiddlewareFor($name));
45
    }
46
47
    public static function anyMethod(string $pattern, string $name): Route
48
    {
49
        return Route::anyMethod($pattern)->middleware(static::buildMiddlewareFor($name));
50
    }
51
52
    public static function buildMiddlewareFor(string $name): Closure
53
    {
54
        return EndpointMiddleware::for($name);
55
    }
56
}
57