Std::addRoute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 10
cc 2
nc 2
nop 2
crap 2
1
<?php declare(strict_types=1);
2
3
namespace Phact\Router\ReverserDataGenerator;
4
5
use FastRoute\BadRouteException;
6
use Phact\Router\ReverserDataGenerator;
7
8
class Std implements ReverserDataGenerator
9
{
10
    protected $routes = [];
11
12
    /**
13
     * @inheritDoc
14
     */
15 11
    public function addRoute(string $routeName, $routeData): void
16
    {
17 11
        if (isset($this->routes[$routeName])) {
18 1
            throw new BadRouteException(sprintf(
19 1
                'Cannot register two routes with same name "%s"',
20 1
                $routeName
21
            ));
22
        }
23 11
        $this->routes[$routeName] = $routeData;
24 11
    }
25
26
    /**
27
     * @inheritDoc
28
     */
29 15
    public function getData(): array
30
    {
31 15
        return $this->routes;
32
    }
33
}
34