Controller::getModifiers()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the silex-annotation-provider package.
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @license       MIT License
9
 * @copyright (c) 2018, Dana Desrosiers <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace DDesrosiers\SilexAnnotations\Annotations;
15
16
/**
17
 * Class Controller defines a Silex Controller Collection and its modifiers and Routes.
18
 *
19
 * @author Dana Desrosiers <[email protected]>
20
 */
21
class Controller
22
{
23
    /** @var string */
24
    public $prefix;
25
26
    /** @var string[] */
27
    private $modifiers;
28
29
    /** @var Route[] */
30
    private $routes;
31
32
    /**
33
     * @param null|string $prefix
34
     */
35
    public function __construct(?string $prefix = '/')
36
    {
37
        $this->prefix = ($prefix[0] !== '/') ? "/$prefix" : $prefix;
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function getPrefix(): string
44
    {
45
        return $this->prefix;
46
    }
47
48
    /**
49
     * @return string[][]
50
     */
51
    public function getModifiers(): array
52
    {
53
        return $this->modifiers;
54
    }
55
56
    /**
57
     * @return Route[]
58
     */
59
    public function getRoutes(): array
60
    {
61
        return $this->routes ?? [];
62
    }
63
64
    /**
65
     * @param string[] $modifiers
66
     */
67
    public function setModifiers(array $modifiers)
68
    {
69
        $this->modifiers = $modifiers;
70
    }
71
72
    /**
73
     * @param Route $route
74
     */
75
    public function addRoute(Route $route)
76
    {
77
        $this->routes[] = $route;
78
    }
79
}