Passed
Push — dev ( c12b3a...6ad196 )
by Janko
24:31 queued 10:07
created

SpacecraftShieldsTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMaxShield() 0 8 3
1
<?php
2
3
namespace Stu\Component\Spacecraft\Trait;
4
5
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
6
7
trait SpacecraftShieldsTrait
8
{
9
    use SpacecraftTrait;
10
    use HasSpacecraftSystemTrait;
11
12
    /**
13
     * proportional to shield system status
14
     */
15 9
    public function getMaxShield(bool $isTheoretical = false): int
16
    {
17 9
        if ($isTheoretical || !$this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::SHIELDS)) {
18 5
            return $this->max_schilde;
19
        }
20
21 7
        return (int) (ceil($this->max_schilde
22 7
            * $this->getSpacecraftSystem(SpacecraftSystemTypeEnum::SHIELDS)->getStatus() / 100));
23
    }
24
}
25