Passed
Pull Request — master (#2138)
by Janko
39:06 queued 27:26
created

TholianWeb::getFleet()   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 1
    public function __construct()
33
    {
34 1
        parent::__construct();
35 1
        $this->capturedSpacecrafts = new ArrayCollection();
36
    }
37
38
    #[Override]
39
    public function getType(): SpacecraftTypeEnum
40
    {
41
        return SpacecraftTypeEnum::THOLIAN_WEB;
42
    }
43
44
    #[Override]
45
    public function getFleet(): ?FleetInterface
46
    {
47
        return null;
48
    }
49
50
    #[Override]
51
    public function getFinishedTime(): ?int
52
    {
53
        return $this->finished_time;
54
    }
55
56
    #[Override]
57
    public function setFinishedTime(?int $time): TholianWebInterface
58
    {
59
        $this->finished_time = $time;
60
61
        return $this;
62
    }
63
64
    #[Override]
65
    public function isFinished(): bool
66
    {
67
        //uninitialized
68
        if ($this->finished_time === 0) {
69
            return false;
70
        }
71
72
        //finished
73
        if ($this->finished_time === null) {
74
            return true;
75
        }
76
77
        return $this->finished_time < time();
78
    }
79
80
    #[Override]
81
    public function getCapturedSpacecrafts(): Collection
82
    {
83
        return $this->capturedSpacecrafts;
84
    }
85
86
    #[Override]
87
    public function updateFinishTime(int $time): void
88
    {
89
        $this->finished_time = $time;
90
    }
91
92
    #[Override]
93
    public function getTransferEntityType(): TransferEntityTypeEnum
94
    {
95
        throw new RuntimeException('unsupported operation');
96
    }
97
}
98