Passed
Pull Request — master (#2112)
by Janko
10:38
created

Crew::__toString()   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
rs 10
c 0
b 0
f 0
ccs 0
cts 2
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\ORM\Mapping\Column;
8
use Doctrine\ORM\Mapping\Entity;
9
use Doctrine\ORM\Mapping\GeneratedValue;
10
use Doctrine\ORM\Mapping\Id;
11
use Doctrine\ORM\Mapping\JoinColumn;
12
use Doctrine\ORM\Mapping\ManyToOne;
13
use Doctrine\ORM\Mapping\Table;
14
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...
15
use Stu\Component\Crew\CrewEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Crew\CrewEnum 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...
16
use Stu\Orm\Repository\CrewRepository;
17
18
#[Table(name: 'stu_crew')]
19
#[Entity(repositoryClass: CrewRepository::class)]
20
class Crew implements CrewInterface
21
{
22
    #[Id]
23
    #[Column(type: 'integer')]
24
    #[GeneratedValue(strategy: 'IDENTITY')]
25
    private int $id;
26
27
    #[Column(type: 'smallint')]
28
    private int $type = 0;
29
30
    #[Column(type: 'smallint')]
31
    private int $gender = 0;
32
33
    #[Column(type: 'string')]
34
    private string $name = '';
35
36
    #[Column(type: 'integer')]
37
    private int $user_id = 0;
38
39
    #[Column(type: 'integer')]
40
    private int $race_id = 0;
41
42
    #[ManyToOne(targetEntity: 'CrewRace')]
43
    #[JoinColumn(name: 'race_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
44
    private CrewRaceInterface $race;
45
46
    #[ManyToOne(targetEntity: 'User')]
47
    #[JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
48
    private UserInterface $user;
49
50 1
    #[Override]
51
    public function getId(): int
52
    {
53 1
        return $this->id;
54
    }
55
56 1
    #[Override]
57
    public function getType(): int
58
    {
59 1
        return $this->type;
60
    }
61
62
    #[Override]
63
    public function setType(int $type): CrewInterface
64
    {
65
        $this->type = $type;
66
67
        return $this;
68
    }
69
70 1
    #[Override]
71
    public function getGender(): int
72
    {
73 1
        return $this->gender;
74
    }
75
76
    #[Override]
77
    public function setGender(int $gender): CrewInterface
78
    {
79
        $this->gender = $gender;
80
81
        return $this;
82
    }
83
84 1
    #[Override]
85
    public function getName(): string
86
    {
87 1
        return $this->name;
88
    }
89
90
    #[Override]
91
    public function setName(string $name): CrewInterface
92
    {
93
        $this->name = $name;
94
95
        return $this;
96
    }
97
98
    public function getUserId(): int
99
    {
100
        return $this->user_id;
101
    }
102
103 5
    #[Override]
104
    public function getUser(): UserInterface
105
    {
106 5
        return $this->user;
107
    }
108
109
    #[Override]
110
    public function setUser(UserInterface $user): CrewInterface
111
    {
112
        $this->user = $user;
113
114
        return $this;
115
    }
116
117
    #[Override]
118
    public function getRaceId(): int
119
    {
120
        return $this->race_id;
121
    }
122
123
    #[Override]
124
    public function setRaceId(int $raceId): CrewInterface
125
    {
126
        $this->race_id = $raceId;
127
128
        return $this;
129
    }
130
131 1
    #[Override]
132
    public function getGenderShort(): string
133
    {
134 1
        if ($this->getGender() == CrewEnum::CREW_GENDER_MALE) {
135 1
            return 'm';
136
        }
137 1
        return 'w';
138
    }
139
140 1
    #[Override]
141
    public function getTypeDescription(): string
142
    {
143 1
        return CrewEnum::getDescription($this->getType());
144
    }
145
146 1
    #[Override]
147
    public function getRace(): CrewRaceInterface
148
    {
149 1
        return $this->race;
150
    }
151
152
    #[Override]
153
    public function setRace(CrewRaceInterface $crewRace): CrewInterface
154
    {
155
        $this->race = $crewRace;
156
157
        return $this;
158
    }
159
160
    #[Override]
161
    public function __toString(): string
162
    {
163
        return sprintf('crewId: %d', $this->getId());
164
    }
165
}
166