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

SpacecraftCountData::isDubious()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
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