Passed
Push — dev ( 5b1d95...923b08 )
by Janko
23:33 queued 07:31
created

LifeSupportCheckHandler::handleSpacecraftTick()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 17
ccs 0
cts 7
cp 0
crap 12
rs 10
1
<?php
2
3
namespace Stu\Module\Tick\Spacecraft\Handler;
4
5
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
7
use Stu\Lib\Information\InformationInterface;
8
use Stu\Module\Spacecraft\Lib\Crew\SpacecraftLeaverInterface;
9
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface;
10
use Stu\Module\Tick\Spacecraft\SpacecraftTickFinishedException;
11
12
class LifeSupportCheckHandler implements SpacecraftTickHandlerInterface
13
{
14 1
    public function __construct(
15
        private SpacecraftLeaverInterface $spacecraftLeaver
16 1
    ) {}
17
18
    #[Override]
19
    public function handleSpacecraftTick(
20
        SpacecraftWrapperInterface $wrapper,
21
        InformationInterface $information
22
    ): void {
23
24
        $spacecraft = $wrapper->get();
25
26
        // leave spacecraft
27
        if (
28
            $spacecraft->getCrewCount() > 0
29
            && !$spacecraft->isSystemHealthy(SpacecraftSystemTypeEnum::LIFE_SUPPORT)
30
        ) {
31
            $information->addInformation('Die Lebenserhaltung ist ausgefallen:');
32
            $information->addInformation($this->spacecraftLeaver->evacuate($wrapper));
33
34
            throw new SpacecraftTickFinishedException();
35
        }
36
    }
37
}
38