TileHandlerCollector::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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