Passed
Push — dev ( 117aec...fd7324 )
by Janko
15:18
created

SpacecraftTractorPayloadTrait::getTractorPayload()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
ccs 4
cts 5
cp 0.8
crap 2.032
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\Trait;
6
7
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
8
use Stu\Orm\Entity\SpacecraftInterface;
9
10
trait SpacecraftTractorPayloadTrait
11
{
12
    /**
13
     * proportional to tractor beam system status
14
     */
15 1
    protected function getTractorPayload(SpacecraftInterface $spacecraft): int
16
    {
17 1
        if (!$spacecraft->hasSpacecraftSystem(SpacecraftSystemTypeEnum::TRACTOR_BEAM)) {
18
            return 0;
19
        }
20
21 1
        return (int) (ceil($spacecraft->getRump()->getTractorPayload()
22 1
            * $spacecraft->getSpacecraftSystem(SpacecraftSystemTypeEnum::TRACTOR_BEAM)->getStatus() / 100));
23
    }
24
}
25