Passed
Pull Request — master (#2027)
by Nico
21:19 queued 10:33
created

SpacecraftCountData   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSpacecraftCount() 0 3 1
A isEnabled() 0 4 2
A isDubious() 0 4 2
A hasCloakedShips() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\Map\VisualPanel\Layer\Data;
6
7
use Doctrine\ORM\Mapping\Column;
8
use Doctrine\ORM\Mapping\Entity;
9
use Stu\Lib\Map\FieldTypeEffectEnum;
10
11
#[Entity]
12
class SpacecraftCountData extends AbstractData
13
{
14
    #[Column(type: 'integer')]
15
    private int $spacecraftcount = 0;
16
    #[Column(type: 'integer')]
17
    private int $cloakcount = 0;
18
19
    /** @var null|array<string> */
20
    #[Column(type: 'json', nullable: true)]
21
    private ?array $effects = null;
22
23 4
    public function getSpacecraftCount(): int
24
    {
25 4
        return $this->spacecraftcount;
26
    }
27
28 4
    public function hasCloakedShips(): bool
29
    {
30 4
        return $this->cloakcount > 0;
31
    }
32
33 4
    public function isEnabled(): bool
34
    {
35 4
        return $this->effects === null
36 4
            || !in_array(FieldTypeEffectEnum::NO_SPACECRAFT_COUNT->value, $this->effects);
37
    }
38
39 4
    public function isDubious(): bool
40
    {
41 4
        return $this->effects !== null
42 4
            && in_array(FieldTypeEffectEnum::DUBIOUS_SPACECRAFT_COUNT->value, $this->effects);
43
    }
44
}
45