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

SpacecraftTorpedoTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 30
ccs 8
cts 14
cp 0.5714
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMaxTorpedos() 0 5 2
A getTorpedo() 0 8 2
A getTorpedoCount() 0 8 2
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