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

RoutePattern   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 83
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getMethod() 0 4 1
A getPattern() 0 4 1
A getHandler() 0 4 1
A setMethod() 0 4 1
A setPattern() 0 4 1
A setHandler() 0 4 1
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