Completed
Push — master ( ed5538...a8c82f )
by Pierre
08:46
created

Route   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 47
ccs 13
cts 13
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
A getExpr() 0 3 1
A getMethod() 0 3 1
1
<?php
2
3
namespace App\Component\Http;
4
5
class Route
6
{
7
8
    protected $method;
9
    protected $expr;
10
    protected $callable;
11
12
    /**
13
     * instanciate
14
     *
15
     * @param string $routeItem
16
     */
17 4
    public function __construct(string $routeItem)
18
    {
19 4
        $this->method = 'GET';
20 4
        $this->expr = '/^(*.)$/';
21
        $this->callable = function () {
22
        };
23 4
        if (strpos($routeItem, ';') !== false) {
24
            list(
25 1
                $this->method,
26 1
                $this->expr,
27 1
                $this->callable
28 1
            ) = explode(';', $routeItem);
29
        } else {
30 4
            $this->expr = $routeItem;
31
        }
32
    }
33
34
    /**
35
     * return regexp pattern
36
     *
37
     * @return string
38
     */
39 2
    public function getExpr(): string
40
    {
41 2
        return $this->expr;
42
    }
43
44
    /**
45
     * return required request method
46
     *
47
     * @return string
48
     */
49 2
    public function getMethod(): string
50
    {
51 2
        return $this->method;
52
    }
53
}
54