RouteCollectionMapTrait   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 0

Complexity

Total Complexity 7

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 104
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
map() 0 1 ?
A get() 0 4 1
A post() 0 4 1
A put() 0 4 1
A patch() 0 4 1
A delete() 0 4 1
A head() 0 4 1
A options() 0 4 1
1
<?php
2
3
namespace League\Route;
4
5
trait RouteCollectionMapTrait
6
{
7
    /**
8
     * Add a route to the map.
9
     *
10
     * @param array|string    $method
11
     * @param string          $path
12
     * @param string|callable $handler
13
     *
14
     * @return \League\Route\Route
15
     */
16
    abstract public function map($method, $path, $handler);
17
18
    /**
19
     * Add a route that responds to GET HTTP method.
20
     *
21
     * @param string          $path
22
     * @param string|callable $handler
23
     *
24
     * @return \League\Route\Route
25
     */
26 6
    public function get($path, $handler)
27
    {
28 6
        return $this->map('GET', $path, $handler);
29
    }
30
31
    /**
32
     * Add a route that responds to POST HTTP method.
33
     *
34
     * @param string          $path
35
     * @param string|callable $handler
36
     *
37
     * @return \League\Route\Route
38
     */
39 3
    public function post($path, $handler)
40
    {
41 3
        return $this->map('POST', $path, $handler);
42
    }
43
44
    /**
45
     * Add a route that responds to PUT HTTP method.
46
     *
47
     * @param string          $path
48
     * @param string|callable $handler
49
     *
50
     * @return \League\Route\Route
51
     */
52 3
    public function put($path, $handler)
53
    {
54 3
        return $this->map('PUT', $path, $handler);
55
    }
56
57
    /**
58
     * Add a route that responds to PATCH HTTP method.
59
     *
60
     * @param string          $path
61
     * @param string|callable $handler
62
     *
63
     * @return \League\Route\Route
64
     */
65 3
    public function patch($path, $handler)
66
    {
67 3
        return $this->map('PATCH', $path, $handler);
68
    }
69
70
    /**
71
     * Add a route that responds to DELETE HTTP method.
72
     *
73
     * @param string          $path
74
     * @param string|callable $handler
75
     *
76
     * @return \League\Route\Route
77
     */
78 3
    public function delete($path, $handler)
79
    {
80 3
        return $this->map('DELETE', $path, $handler);
81
    }
82
83
    /**
84
     * Add a route that responds to HEAD HTTP method.
85
     *
86
     * @param string          $path
87
     * @param string|callable $handler
88
     *
89
     * @return \League\Route\Route
90
     */
91 3
    public function head($path, $handler)
92
    {
93 3
        return $this->map('HEAD', $path, $handler);
94
    }
95
96
    /**
97
     * Add a route that responds to OPTIONS HTTP method.
98
     *
99
     * @param string          $path
100
     * @param string|callable $handler
101
     *
102
     * @return \League\Route\Route
103
     */
104 3
    public function options($path, $handler)
105
    {
106 3
        return $this->map('OPTIONS', $path, $handler);
107
    }
108
}
109