Test Failed
Branch develop (ab83c3)
by Bohuslav
02:47
created

Base   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 111
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 111
c 0
b 0
f 0
wmc 7
lcom 0
cbo 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setMethod() 0 6 1
A getMethod() 0 4 1
A setUrl() 0 6 1
A getUrl() 0 4 1
A setHandler() 0 6 1
A getHandler() 0 4 1
1
<?php
2
3
namespace Kambo\Router\Route\Route;
4
5
use Kambo\Router\Route\Route;
6
7
/**
8
 * Class representing the base Route
9
 *
10
 * @package Kambo\Router\Route\Route
11
 * @author  Bohuslav Simek <[email protected]>
12
 * @license MIT
13
 */
14
class Base implements Route
15
{
16
    /**
17
     * Route methog, eg.: GET, POST, ...
18
     *
19
     * @var string
20
     */
21
    private $method;
22
23
    /**
24
     * Route handler, can be callable or array, this is connected
25
     * with the selected dispatcher.
26
     *
27
     * @var mixed
28
     */
29
    private $handler;
30
31
    /**
32
     * Route url eg. /foo/bar
33
     *
34
     * @var string
35
     */
36
    private $url;
37
38
    /**
39
     * Route constructor
40
     *
41
     * @param String $method
42
     * @param String $url
43
     * @param Mixed  $handler
44
     */
45
    public function __construct($method, $url, $handler)
46
    {
47
        $this->method  = $method;
48
        $this->handler = $handler;
49
        $this->url     = $url;
50
    }
51
52
    /**
53
     * Sets route method
54
     *
55
     * @param string $method route method
56
     *
57
     * @return self for fluent interface
58
     */
59
    public function setMethod($method)
60
    {
61
        $this->method = $method;
62
63
        return $this;
64
    }
65
66
    /**
67
     * Get route method
68
     *
69
     * @return string
70
     */
71
    public function getMethod()
72
    {
73
        return $this->method;
74
    }
75
76
    /**
77
     * Sets URL for route
78
     *
79
     * @param mixed $url route url
80
     *
81
     * @return self for fluent interface
82
     */
83
    public function setUrl($url)
84
    {
85
        $this->url = $url;
86
87
        return $this;
88
    }
89
90
    /**
91
     * Get URL of route
92
     *
93
     * @return string
94
     */
95
    public function getUrl()
96
    {
97
        return $this->url;
98
    }
99
100
    /**
101
     * Sets handler that will be executed if the url will match the route.
102
     *
103
     * @param mixed $handler handler which will be executed if the url will
104
     *                       match the route
105
     *
106
     * @return self for fluent interface
107
     */
108
    public function setHandler($handler)
109
    {
110
        $this->handler = $handler;
111
112
        return $this;
113
    }
114
115
    /**
116
     * Get handler
117
     *
118
     * @return mixed
119
     */
120
    public function getHandler()
121
    {
122
        return $this->handler;
123
    }
124
}
125