Passed
Push — master ( b202e3...14e011 )
by Divine Niiquaye
02:35 queued 13s
created

RouteGroup::addScheme()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Flight Routing.
7
 *
8
 * PHP version 7.1 and above required
9
 *
10
 * @author    Divine Niiquaye Ibok <[email protected]>
11
 * @copyright 2019 Biurad Group (https://biurad.com/)
12
 * @license   https://opensource.org/licenses/BSD-3-Clause License
13
 *
14
 * For the full copyright and license information, please view the LICENSE
15
 * file that was distributed with this source code.
16
 */
17
18
namespace Flight\Routing;
19
20
use Flight\Routing\Interfaces\RouteCollectionInterface;
21
use Flight\Routing\Interfaces\RouteGroupInterface;
22
use Flight\Routing\Interfaces\RouteInterface;
23
24
class RouteGroup implements RouteGroupInterface
25
{
26
    /**
27
     * Route collection for group activities
28
     *
29
     * @var RouteCollectionInterface|RouteInterface[]
30
     */
31
    private $collection;
32
33
    /**
34
     * Constructor of the class
35
     *
36
     * @param RouteCollectionInterface $collection
37
     */
38 2
    public function __construct(RouteCollectionInterface $collection)
39
    {
40 2
        $this->collection = $collection;
41 2
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    public function setDefaults(array $defaults): RouteGroupInterface
47
    {
48 1
        foreach ($this->collection as $route) {
49 1
            $route->setDefaults($defaults);
50
        }
51
52 1
        return $this;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 1
    public function setName(string $name): RouteGroupInterface
59
    {
60 1
        foreach ($this->collection as $route) {
61 1
            $route->setName($name . $route->getName());
62
        }
63
64 1
        return $this;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70 1
    public function addPrefix(string $prefix): RouteGroupInterface
71
    {
72 1
        foreach ($this->collection as $route) {
73 1
            $route->addPrefix($prefix);
74
        }
75
76 1
        return $this;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82 1
    public function addDomain(string $domain): RouteGroupInterface
83
    {
84 1
        foreach ($this->collection as $route) {
85 1
            $route->setDomain($domain);
86
        }
87
88 1
        return $this;
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94 1
    public function addScheme(string ...$schemes): RouteGroupInterface
95
    {
96 1
        foreach ($this->collection as $route) {
97 1
            $route->setScheme(...$schemes);
98
        }
99
100 1
        return $this;
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106 1
    public function addMethod(string ...$methods): RouteGroupInterface
107
    {
108 1
        foreach ($this->collection as $route) {
109 1
            $route->addMethod(...$methods);
110
        }
111
112 1
        return $this;
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118 1
    public function addMiddleware(...$middlewares): RouteGroupInterface
119
    {
120 1
        foreach ($this->collection as $route) {
121 1
            $route->addMiddleware(...$middlewares);
122
        }
123
124 1
        return $this;
125
    }
126
}
127