Completed
Push — master ( 018e09...23dba2 )
by Andrii
11:58
created

EndpointRoute   A

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 hiapi\Core\Http\Psr15\Middleware\EndpointMiddleware;
7
use Yiisoft\Router\Route;
8
9
class EndpointRoute
10
{
11
    public static function get(string $pattern, string $name): Route
12
    {
13
        return Route::get($pattern, static::buildMiddlewareFor($name));
14
    }
15
16
    public static function post(string $pattern, string $name): Route
17
    {
18
        return Route::post($pattern, static::buildMiddlewareFor($name));
19
    }
20
21
    public static function put(string $pattern, string $name): Route
22
    {
23
        return Route::put($pattern, static::buildMiddlewareFor($name));
24
    }
25
26
    public static function delete(string $pattern, string $name): Route
27
    {
28
        return Route::delete($pattern, static::buildMiddlewareFor($name));
29
    }
30
31
    public static function patch(string $pattern, string $name): Route
32
    {
33
        return Route::patch($pattern, static::buildMiddlewareFor($name));
34
    }
35
36
    public static function head(string $pattern, string $name): Route
37
    {
38
        return Route::head($pattern, static::buildMiddlewareFor($name));
39
    }
40
41
    public static function options(string $pattern, string $name): Route
42
    {
43
        return Route::options($pattern, static::buildMiddlewareFor($name));
44
    }
45
46
    public static function anyMethod(string $pattern, string $name): Route
47
    {
48
        return Route::anyMethod($pattern, static::buildMiddlewareFor($name));
49
    }
50
51
    public static function buildMiddlewareFor(string $name): \Closure
52
    {
53
        return EndpointMiddleware::for($name);
54
    }
55
}
56