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

SpacecraftInteractionTrait   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A canIntercept() 0 7 4
A canMove() 0 4 2
A isBoardingPossible() 0 3 1
A isInterceptable() 0 4 1
A isTractorbeamPossible() 0 3 1
1
<?php
2
3
namespace Stu\Component\Spacecraft\Trait;
4
5
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
6
use Stu\Component\Spacecraft\System\Type\TractorBeamShipSystem;
7
use Stu\Module\Spacecraft\Lib\Battle\FightLib;
8
use Stu\Orm\Entity\ShipInterface;
9
10
trait SpacecraftInteractionTrait
11
{
12
    use SpacecraftTrait;
13
    use HasSpacecraftSystemTrait;
14
    use SpacecraftSystemHealthTrait;
15
16
    public function isTractorbeamPossible(): bool
17
    {
18
        return TractorBeamShipSystem::isTractorBeamPossible($this);
0 ignored issues
show
Bug introduced by
$this of type Stu\Component\Spacecraft...cecraftInteractionTrait is incompatible with the type Stu\Module\Spacecraft\Li...ity\SpacecraftInterface expected by parameter $spacecraft of Stu\Component\Spacecraft...isTractorBeamPossible(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
        return TractorBeamShipSystem::isTractorBeamPossible(/** @scrutinizer ignore-type */ $this);
Loading history...
19
    }
20
21
    public function isBoardingPossible(): bool
22
    {
23
        return FightLib::isBoardingPossible($this);
0 ignored issues
show
Bug introduced by
$this of type Stu\Component\Spacecraft...cecraftInteractionTrait is incompatible with the type Stu\Module\Spacecraft\Li...ity\SpacecraftInterface expected by parameter $object of Stu\Module\Spacecraft\Li...b::isBoardingPossible(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
        return FightLib::isBoardingPossible(/** @scrutinizer ignore-type */ $this);
Loading history...
24
    }
25
26
    public function isInterceptable(): bool
27
    {
28
        //TODO can tractored ships be intercepted?!
29
        return $this->getThis()->getWarpDriveState();
30
    }
31
32 1
    public function canIntercept(): bool
33
    {
34 1
        $self = $this->getThis();
35
36 1
        return $this->isSystemHealthy(SpacecraftSystemTypeEnum::WARPDRIVE)
37 1
            && !$self->isTractoring()
38 1
            && (!$self instanceof ShipInterface || !$self->isTractored());
39
    }
40
41 3
    public function canMove(): bool
42
    {
43 3
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::WARPDRIVE)
44 3
            || $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::IMPULSEDRIVE);
45
    }
46
}
47