Passed
Pull Request — master (#2138)
by Janko
24:59 queued 14:00
created

SpacecraftTractorPayloadTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 13
rs 10
c 0
b 0
f 0
ccs 4
cts 5
cp 0.8
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 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