Route   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 66
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getMethod() 0 4 1
A getUri() 0 4 1
A getControllerName() 0 4 1
A getModifiers() 0 4 1
A setModifiers() 0 4 1
1
<?php
2
/**
3
 * This file is part of the silex-annotation-provider package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @license       MIT License
8
 * @copyright (c) 2018, Dana Desrosiers <[email protected]>
9
 */
10
11
declare(strict_types=1);
12
13
namespace DDesrosiers\SilexAnnotations\Annotations;
14
15
/**
16
 * Class Route defines a Silex endpoint and its modifiers.
17
 *
18
 * @author Dana Desrosiers <[email protected]>
19
 */
20
class Route
21
{
22
    /** @var string */
23
    public $controllerName;
24
25
    /** @var string */
26
    public $method;
27
28
    /** @var string */
29
    public $uri;
30
31
    /** @var string[][] */
32
    public $modifiers;
33
34
    /**
35
     * @param string $controllerName
36
     * @param string $uri
37
     */
38
    public function __construct(string $controllerName, string $uri)
39
    {
40
        $this->controllerName = $controllerName;
41
        $uri = explode(' ', $uri);
42
        $this->uri = array_pop($uri);
43
        $this->method = count($uri) > 0 ? array_shift($uri) : 'MATCH';
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getMethod(): string
50
    {
51
        return $this->method;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getUri(): string
58
    {
59
        return $this->uri;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getControllerName(): string
66
    {
67
        return $this->controllerName;
68
    }
69
70
    /**
71
     * @return string[][]
72
     */
73
    public function getModifiers(): array
74
    {
75
        return $this->modifiers;
76
    }
77
78
    /**
79
     * @param string[][] $modifiers
80
     */
81
    public function setModifiers(array $modifiers)
82
    {
83
        $this->modifiers = $modifiers;
84
    }
85
}