Passed
Push — dev ( 80c162...225d4f )
by Janko
09:12
created

TholianWeb::getCapturedShips()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
use Doctrine\ORM\Mapping\Column;
10
use Doctrine\ORM\Mapping\Entity;
11
use Doctrine\ORM\Mapping\OneToMany;
12
use Doctrine\ORM\Mapping\Table;
13
use Override;
0 ignored issues
show
Bug introduced by
The type Override 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...
14
use RuntimeException;
15
use Stu\Component\Spacecraft\SpacecraftTypeEnum;
16
use Stu\Lib\Transfer\TransferEntityTypeEnum;
17
use Stu\Orm\Repository\TholianWebRepository;
18
19
#[Table(name: 'stu_tholian_web')]
20
#[Entity(repositoryClass: TholianWebRepository::class)]
21
class TholianWeb extends Spacecraft implements TholianWebInterface
22
{
23
    #[Column(type: 'integer', nullable: true)]
24
    private ?int $finished_time = 0;
25
26
    /**
27
     * @var ArrayCollection<int, SpacecraftInterface>
28
     */
29
    #[OneToMany(targetEntity: 'Spacecraft', mappedBy: 'holdingWeb')]
30
    private Collection $capturedSpacecrafts;
31
32
    public function __construct()
33
    {
34
        $this->capturedSpacecrafts = new ArrayCollection();
35
    }
36
37
    #[Override]
38
    public function getType(): SpacecraftTypeEnum
39
    {
40
        return SpacecraftTypeEnum::THOLIAN_WEB;
41
    }
42
43
    #[Override]
44
    public function getFleet(): ?FleetInterface
45
    {
46
        return null;
47
    }
48
49
    #[Override]
50
    public function getFinishedTime(): ?int
51
    {
52
        return $this->finished_time;
53
    }
54
55
    #[Override]
56
    public function setFinishedTime(?int $time): TholianWebInterface
57
    {
58
        $this->finished_time = $time;
59
60
        return $this;
61
    }
62
63
    #[Override]
64
    public function isFinished(): bool
65
    {
66
        //uninitialized
67
        if ($this->finished_time === 0) {
68
            return false;
69
        }
70
71
        //finished
72
        if ($this->finished_time === null) {
73
            return true;
74
        }
75
76
        return $this->finished_time < time();
77
    }
78
79
    #[Override]
80
    public function getCapturedSpacecrafts(): Collection
81
    {
82
        return $this->capturedSpacecrafts;
83
    }
84
85
    #[Override]
86
    public function updateFinishTime(int $time): void
87
    {
88
        $this->finished_time = $time;
89
    }
90
91
    #[Override]
92
    public function getTransferEntityType(): TransferEntityTypeEnum
93
    {
94
        throw new RuntimeException('unsupported operation');
95
    }
96
}
97