CollectionRoute::getRoutes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace PTS\Routing;
5
6
use PTS\Tools\Collection;
7
use PTS\Tools\DuplicateKeyException;
8
9
class CollectionRoute extends Collection
10
{
11
12
    /**
13
     * @param string $name
14
     * @param Route $route
15
     * @param int $priority
16
     *
17
     * @return $this
18
     *
19
     * @throws DuplicateKeyException
20
     */
21 12
    public function add(string $name, Route $route, int $priority = 50): self
22
    {
23 12
        return $this->addItem($name, $route, $priority);
24
    }
25
26 1
    public function remove(string $name): self
27
    {
28 1
        return $this->removeItemWithoutPriority($name);
29
    }
30
31
    /**
32
     * @return Route[]
33
     */
34 11
    public function getRoutes(): array
35
    {
36 11
        return $this->getFlatItems(true);
37
    }
38
}
39