Passed
Push — dev ( 98511f...00baf5 )
by Janko
15:17
created

SpacecraftTorpedoTrait::getMaxTorpedos()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Stu\Component\Spacecraft\Trait;
4
5
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
6
use Stu\Component\Spacecraft\System\Type\TorpedoStorageShipSystem;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Spacecraft...orpedoStorageShipSystem was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Stu\Orm\Entity\TorpedoTypeInterface;
8
9
trait SpacecraftTorpedoTrait
10
{
11
    use SpacecraftTrait;
12
    use SpacecraftSystemHealthTrait;
13
14
    public function getTorpedoCount(): int
15
    {
16
        $torpedoStorage = $this->getThis()->getTorpedoStorage();
17
        if ($torpedoStorage === null) {
18
            return 0;
19
        }
20
21
        return $torpedoStorage->getStorage()->getAmount();
22
    }
23
24 3
    public function getTorpedo(): ?TorpedoTypeInterface
25
    {
26 3
        $torpedoStorage = $this->getThis()->getTorpedoStorage();
27 3
        if ($torpedoStorage === null) {
28 3
            return null;
29
        }
30
31
        return $torpedoStorage->getTorpedo();
32
    }
33
34 3
    public function getMaxTorpedos(): int
35
    {
36 3
        return $this->getThis()->getRump()->getBaseTorpedoStorage()
37 3
            + ($this->isSystemHealthy(SpacecraftSystemTypeEnum::TORPEDO_STORAGE)
38 3
                ? TorpedoStorageShipSystem::TORPEDO_CAPACITY : 0);
39
    }
40
}
41