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

Route::getMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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