TileHandlerCollector   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PanicLabCore\Services\Handlers;
6
7
use PanicLabCore\Structs\Step;
8
use PanicLabCore\Structs\Target;
9
10
class TileHandlerCollector implements TileHandlerCollectorInterface
11
{
12
    /** @var \Traversable */
13
    private $tileHandlers;
14
15 24
    public function __construct(\Traversable $tileHandlers)
16
    {
17 24
        $this->tileHandlers = $tileHandlers;
18 24
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 6
    public function handle(array $tiles, Target $target, Step $stepStruct): void
24
    {
25
        /** @var TileHandlerInterface $tileHandler */
26 6
        foreach ($this->tileHandlers as $tileHandler) {
27 6
            $tile = $tiles[$stepStruct->getCurrentIndex()];
28 6
            if (!$tileHandler->supports($tile)) {
29 6
                continue;
30
            }
31
32 6
            $tileHandler->handle($tiles, $target, $stepStruct);
33
        }
34 6
    }
35
}
36