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

SpacecraftEvadeChanceTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

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

1 Method

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