Test Failed
Pull Request — master (#2138)
by Nico
07:39
created

SpacecraftTractorPayloadTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 13
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTractorPayload() 0 8 2
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
    protected function getTractorPayload(SpacecraftInterface $spacecraft): int
16
    {
17
        if (!$spacecraft->hasSpacecraftSystem(SpacecraftSystemTypeEnum::TRACTOR_BEAM)) {
18
            return 0;
19
        }
20
21
        return (int) (ceil($spacecraft->getRump()->getTractorPayload()
22
            * $spacecraft->getSpacecraftSystem(SpacecraftSystemTypeEnum::TRACTOR_BEAM)->getStatus() / 100));
23
    }
24
}
25