Passed
Pull Request — dev (#2038)
by Janko
10:55
created

Crew::getGenderShort()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A Crew::getRaceId() 0 4 1
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\GeneratedValue;
12
use Doctrine\ORM\Mapping\Id;
13
use Doctrine\ORM\Mapping\JoinColumn;
14
use Doctrine\ORM\Mapping\ManyToOne;
15
use Doctrine\ORM\Mapping\OneToMany;
16
use Doctrine\ORM\Mapping\Table;
17
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...
18
use Stu\Component\Crew\CrewGenderEnum;
19
use Stu\Component\Crew\CrewPositionEnum;
20
use Stu\Component\Crew\Skill\CrewSkillLevelEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Crew\Skill\CrewSkillLevelEnum 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...
21
use Stu\Orm\Repository\CrewRepository;
22
23
#[Table(name: 'stu_crew')]
24
#[Entity(repositoryClass: CrewRepository::class)]
25
class Crew implements CrewInterface
26
{
27
    #[Id]
28
    #[Column(type: 'integer')]
29
    #[GeneratedValue(strategy: 'IDENTITY')]
30
    private int $id;
31
32
    #[Column(type: 'string', enumType: CrewSkillLevelEnum::class)]
33
    private CrewSkillLevelEnum $rank = CrewSkillLevelEnum::RECRUIT;
34
35
    #[Column(type: 'smallint', enumType: CrewGenderEnum::class)]
36
    private CrewGenderEnum $gender = CrewGenderEnum::MALE;
37
38
    #[Column(type: 'string')]
39
    private string $name = '';
40
41
    #[Column(type: 'integer')]
42
    private int $user_id = 0;
43
44
    #[Column(type: 'integer')]
45
    private int $race_id = 0;
46
47
    #[ManyToOne(targetEntity: 'CrewRace')]
48
    #[JoinColumn(name: 'race_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
49
    private CrewRaceInterface $race;
50
51
    #[ManyToOne(targetEntity: 'User')]
52
    #[JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
53
    private UserInterface $user;
54
55
    /**
56
     * @var ArrayCollection<int, CrewSkillInterface>
57
     */
58
    #[OneToMany(targetEntity: 'CrewSkill', mappedBy: 'crew', indexBy: 'position', fetch: 'EXTRA_LAZY')]
59
    private Collection $skills;
60
61
    public function __construct()
62
    {
63
        $this->skills = new ArrayCollection();
64
    }
65
66 2
    #[Override]
67
    public function getId(): int
68
    {
69 2
        return $this->id;
70
    }
71
72 1
    #[Override]
73
    public function getRank(): CrewSkillLevelEnum
74
    {
75 1
        return $this->rank;
76
    }
77
78
    #[Override]
79
    public function setRank(CrewSkillLevelEnum $rank): CrewInterface
80
    {
81
        $this->rank = $rank;
82
83
        return $this;
84
    }
85
86 1
    #[Override]
87
    public function getGender(): CrewGenderEnum
88
    {
89 1
        return $this->gender;
90
    }
91
92
    #[Override]
93
    public function setGender(CrewGenderEnum $gender): CrewInterface
94
    {
95
        $this->gender = $gender;
96
97
        return $this;
98
    }
99
100 1
    #[Override]
101
    public function getName(): string
102
    {
103 1
        return $this->name;
104
    }
105
106
    #[Override]
107
    public function setName(string $name): CrewInterface
108
    {
109
        $this->name = $name;
110
111
        return $this;
112
    }
113
114
    public function getUserId(): int
115
    {
116
        return $this->user_id;
117
    }
118
119 6
    #[Override]
120
    public function getUser(): UserInterface
121
    {
122 6
        return $this->user;
123
    }
124
125
    #[Override]
126
    public function setUser(UserInterface $user): CrewInterface
127
    {
128
        $this->user = $user;
129
130
        return $this;
131
    }
132
133
    #[Override]
134
    public function getRaceId(): int
135
    {
136
        return $this->race_id;
137
    }
138
139
    #[Override]
140
    public function setRaceId(int $raceId): CrewInterface
141
    {
142
        $this->race_id = $raceId;
143
144
        return $this;
145
    }
146
147 1
    #[Override]
148
    public function getRace(): CrewRaceInterface
149
    {
150 1
        return $this->race;
151
    }
152
153
    #[Override]
154
    public function setRace(CrewRaceInterface $crewRace): CrewInterface
155
    {
156
        $this->race = $crewRace;
157
158
        return $this;
159
    }
160
161 1
    public function getSkills(): Collection
162
    {
163 1
        return $this->skills;
164
    }
165
166
    #[Override]
167
    public function isSkilledAt(CrewPositionEnum $position): bool
168
    {
169
        return $this->skills->containsKey($position->value);
170
    }
171
172
    #[Override]
173
    public function __toString(): string
174
    {
175
        return sprintf('crewId: %d', $this->getId());
176
    }
177
}
178