Std   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 24
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 3 1
A addRoute() 0 9 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