TileHandlerCollector::handle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 3
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
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