Completed
Pull Request — master (#2)
by Joao
02:23
created

RoutePattern::getMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace ByJG\RestServer;
4
5
use ByJG\RestServer\HandleOutput\JsonHandler;
6
7
class RoutePattern
8
{
9
    /**
10
     * @var string|array
11
     */
12
    protected $method;
13
14
    /**
15
     * @var string
16
     */
17
    protected $pattern;
18
19
    /**
20
     * @var string
21
     */
22
    protected $handler;
23
24
    /**
25
     * RoutePattern constructor.
26
     *
27
     * @param array|string $method
28
     * @param string $pattern
29
     * @param string $handler
30
     */
31
    public function __construct($method, $pattern, $handler = null)
32
    {
33
        $this->method = $method;
34
        $this->pattern = $pattern;
35
36
        if (is_null($handler)) {
37
            $handler = JsonHandler::class;
38
        }
39
        $this->handler = $handler;
40
    }
41
42
    /**
43
     * @return array|string
44
     */
45
    public function getMethod()
46
    {
47
        return $this->method;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getPattern()
54
    {
55
        return $this->pattern;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getHandler()
62
    {
63
        return $this->handler;
64
    }
65
66
    /**
67
     * @param array|string $method
68
     */
69
    public function setMethod($method)
70
    {
71
        $this->method = $method;
72
    }
73
74
    /**
75
     * @param string $pattern
76
     */
77
    public function setPattern($pattern)
78
    {
79
        $this->pattern = $pattern;
80
    }
81
82
    /**
83
     * @param string $handler
84
     */
85
    public function setHandler($handler)
86
    {
87
        $this->handler = $handler;
88
    }
89
}
90