Router   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 7
dl 0
loc 57
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 3 1
A patch() 0 3 1
A __construct() 0 3 1
A get() 0 3 1
A post() 0 3 1
A put() 0 3 1
1
<?php
2
3
namespace KadokWeb\Router;
4
5
6
/**
7
 * Class KadokWeb Router
8
 *
9
 * @author Robson V. Leite <https://github.com/kadokweb>
10
 * @package KadokWeb\Router
11
 */
12
13
class Router extends Dispatch
14
{
15
    /**
16
     * Router constructor.
17
     *
18
     * @param string $projectUrl
19
     * @param null|string $separator
20
     */
21
    public function __construct(string $projectUrl, ?string $separator = ":")
22
    {
23
        parent::__construct($projectUrl, $separator);
24
    }
25
26
27
    /**
28
     * @param string $route
29
     * @param string|callable $handler
30
     */
31
    public function post(string $route, $handler): void
32
    {
33
        $this->addRoute("POST", $route, $handler);
34
    }
35
36
    /**
37
     * @param string $route
38
     * @param string|callable $handler
39
     */
40
    public function get(string $route, $handler): void
41
    {
42
        $this->addRoute("GET", $route, $handler);
43
    }
44
45
    /**
46
     * @param string $route
47
     * @param string|callable $handler
48
     */
49
    public function put(string $route, $handler): void
50
    {
51
        $this->addRoute("PUT", $route, $handler);
52
    }
53
54
    /**
55
     * @param string $route
56
     * @param string|callable $handler
57
     */
58
    public function patch(string $route, $handler): void
59
    {
60
        $this->addRoute("PATCH", $route, $handler);
61
    }
62
63
    /**
64
     * @param string $route
65
     * @param string|callable $handler
66
     */
67
    public function delete(string $route, $handler): void
68
    {
69
        $this->addRoute("DELETE", $route, $handler);
70
    }
71
}