Passed
Push — dev ( 915030...7801e0 )
by Janko
23:47 queued 09:25
created

FallbackRouter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Stu\Module\Control\Router;
4
5
use Stu\Module\Control\GameControllerInterface;
6
use Stu\Module\Control\Router\Handler\FallbackHandlerInterface;
7
8
class FallbackRouter implements FallbackRouterInterface
9
{
10
    /** @param array<FallbackHandlerInterface> $handlers */
11 4
    public function __construct(
12
        private array $handlers
13 4
    ) {}
14
15 2
    public function showFallbackSite(FallbackRouteException $e, GameControllerInterface $game): void
16
    {
17 2
        $className = get_class($e);
18 2
        if (!array_key_exists($className, $this->handlers)) {
19 1
            throw new FallbackRouteException(
20 1
                sprintf('no fallback handler for exception class %s', $className),
21 1
                1,
22 1
                $e
23 1
            );
24
        }
25
26 1
        $this->handlers[$className]->handle($e, $game);
27
    }
28
}
29