Passed
Push — master ( bf860f...1dd8f7 )
by Nico
57:55 queued 29:36
created

ShipDestruction::destroy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 20
ccs 14
cts 14
cp 1
crap 1
rs 9.8333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Ship\Lib\Destruction;
6
7
use Stu\Lib\Information\InformationInterface;
8
use Stu\Module\Ship\Lib\Destruction\Handler\ShipDestructionHandlerInterface;
9
use Stu\Module\Ship\Lib\ShipWrapperInterface;
10
11
final class ShipDestruction implements ShipDestructionInterface
12
{
13
14
    /**
15
     * @param array<ShipDestructionHandlerInterface> $destructionHandlers
16
     */
17 2
    public function __construct(
18
        private array $destructionHandlers
19
    ) {
20 2
    }
21
22 1
    public function destroy(
23
        ?ShipDestroyerInterface $destroyer,
24
        ShipWrapperInterface $destroyedShipWrapper,
25
        ShipDestructionCauseEnum $cause,
26
        InformationInterface $informations
27
    ): void {
28
29 1
        array_walk(
30 1
            $this->destructionHandlers,
31 1
            function (ShipDestructionHandlerInterface $handler) use (
32 1
                $destroyer,
33 1
                $destroyedShipWrapper,
34 1
                $cause,
35 1
                $informations
36 1
            ): void {
37 1
                $handler->handleShipDestruction(
38 1
                    $destroyer,
39 1
                    $destroyedShipWrapper,
40 1
                    $cause,
41 1
                    $informations
42 1
                );
43 1
            }
44 1
        );
45
    }
46
}
47