Passed
Push — dev ( c878e4...99122a )
by Janko
30:05
created

ShipDestruction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 12.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 31
ccs 2
cts 16
cp 0.125
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A destroy() 0 20 1
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 1
    public function __construct(
18
        private array $destructionHandlers
19
    ) {
20 1
    }
21
22
    public function destroy(
23
        ?ShipDestroyerInterface $destroyer,
24
        ShipWrapperInterface $destroyedShipWrapper,
25
        ShipDestructionCauseEnum $cause,
26
        InformationInterface $informations
27
    ): void {
28
29
        array_walk(
30
            $this->destructionHandlers,
31
            function (ShipDestructionHandlerInterface $handler) use (
32
                $destroyer,
33
                $destroyedShipWrapper,
34
                $cause,
35
                $informations
36
            ): void {
37
                $handler->handleShipDestruction(
38
                    $destroyer,
39
                    $destroyedShipWrapper,
40
                    $cause,
41
                    $informations
42
                );
43
            }
44
        );
45
    }
46
}
47