Completed
Push — master ( 49f631...00219d )
by Frank
03:48
created

Router   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 16
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 7 2
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of the package neoblack/free-at-home-api.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE file that was distributed with this source code.
9
 */
10
11
namespace NeoBlack\FreeAtHomeApi\Service;
12
13
use NeoBlack\FreeAtHomeApi\Entity\Route;
14
use NeoBlack\FreeAtHomeApi\Exception\UnknownRouteException;
15
16
class Router
17
{
18
    public const DEVICES_GET = 'DEVICES_GET';
19
20
    private $methods = [
21
        self::DEVICES_GET => ['/devices', Route::METHOD_GET]
22
    ];
23
24 2
    public function get(string $identifier): Route
25
    {
26 2
        if (!isset($this->methods[$identifier])) {
27 1
            throw new UnknownRouteException('The route with identifier "' . $identifier . '" is unknown', 1536351904);
28
        }
29 1
        return new Route($this->methods[$identifier][0], $this->methods[$identifier][1]);
30
    }
31
}
32