Base::getUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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