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

SkillEnhancementLog::setExpertiseSum()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 0
cts 3
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\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\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...
16
use Stu\Orm\Repository\SkillEnhancementLogRepository;
17
18
#[Table(name: 'stu_skill_enhancement_log')]
19
#[Entity(repositoryClass: SkillEnhancementLogRepository::class)]
20
class SkillEnhancementLog implements SkillEnhancementLogInterface
21
{
22
    #[Id]
23
    #[Column(type: 'integer')]
24
    #[GeneratedValue(strategy: 'IDENTITY')]
25
    private int $id;
0 ignored issues
show
introduced by
The private property $id is not used, and could be removed.
Loading history...
26
27
    #[Column(type: 'integer')]
28
    private int $user_id;
0 ignored issues
show
introduced by
The private property $user_id is not used, and could be removed.
Loading history...
29
30
    #[Column(type: 'integer')]
31
    private int $enhancement_id;
0 ignored issues
show
introduced by
The private property $enhancement_id is not used, and could be removed.
Loading history...
32
33
    #[Column(type: 'integer')]
34
    private int $crew_id;
35
36
    #[Column(type: 'string')]
37
    private string $crew_name;
38
39
    #[Column(type: 'string', nullable: true)]
40
    private ?string $promotion;
41
42
    #[Column(type: 'string')]
43
    private string $ship_name;
44
45
    #[Column(type: 'integer')]
46
    private int $expertise;
47
48
    #[Column(type: 'integer')]
49
    private int $expertise_sum;
50
51
    #[Column(type: 'integer')]
52
    private int $date;
53
54
    #[ManyToOne(targetEntity: 'User')]
55
    #[JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
56
    private UserInterface $user;
57
58
    #[ManyToOne(targetEntity: 'SkillEnhancement')]
59
    #[JoinColumn(name: 'enhancement_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
60
    private SkillEnhancementInterface $enhancement;
61
62
    #[Override]
63
    public function setUser(UserInterface $user): SkillEnhancementLogInterface
64
    {
65
        $this->user = $user;
66
67
        return $this;
68
    }
69
70
    #[Override]
71
    public function setEnhancement(SkillEnhancementInterface $enhancement): SkillEnhancementLogInterface
72
    {
73
        $this->enhancement = $enhancement;
74
75
        return $this;
76
    }
77
78
    #[Override]
79
    public function setCrewName(string $crewName): SkillEnhancementLogInterface
80
    {
81
        $this->crew_name = $crewName;
82
83
        return $this;
84
    }
85
86
    #[Override]
87
    public function setShipName(string $shipName): SkillEnhancementLogInterface
88
    {
89
        $this->ship_name = $shipName;
90
91
        return $this;
92
    }
93
94
    #[Override]
95
    public function setCrewId(int $crewId): SkillEnhancementLogInterface
96
    {
97
        $this->crew_id = $crewId;
98
99
        return $this;
100
    }
101
102
    #[Override]
103
    public function getPromotion(): ?string
104
    {
105
        return $this->promotion;
106
    }
107
108
    #[Override]
109
    public function setPromotion(?string $text): SkillEnhancementLogInterface
110
    {
111
        $this->promotion = $text;
112
113
        return $this;
114
    }
115
116
    #[Override]
117
    public function setExpertise(int $amount): SkillEnhancementLogInterface
118
    {
119
        $this->expertise = $amount;
120
121
        return $this;
122
    }
123
124
    #[Override]
125
    public function setExpertiseSum(int $sum): SkillEnhancementLogInterface
126
    {
127
        $this->expertise_sum = $sum;
128
129
        return $this;
130
    }
131
132
    #[Override]
133
    public function getTimestamp(): int
134
    {
135
        return $this->date;
136
    }
137
138
    #[Override]
139
    public function setTimestamp(int $date): SkillEnhancementLogInterface
140
    {
141
        $this->date = $date;
142
143
        return $this;
144
    }
145
146
    #[Override]
147
    public function __toString(): string
148
    {
149
        return sprintf(
150
            '%s (%s) von der %s steigt auf %d (+%d) Expertise%s für %s',
151
            $this->crew_name,
152
            $this->enhancement->getPosition()->getDescription(),
153
            $this->ship_name,
154
            $this->expertise_sum,
155
            $this->expertise,
156
            $this->promotion === null ? sprintf(' (Rang %s)', CrewSkillLevelEnum::getForExpertise($this->expertise)->getDescription()) : '',
157
            $this->enhancement->getDescription()
158
        );
159
    }
160
}
161