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

CrewSkill::increaseExpertise()   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 1
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\ORM\Mapping\Column;
8
use Doctrine\ORM\Mapping\Entity;
9
use Doctrine\ORM\Mapping\Id;
10
use Doctrine\ORM\Mapping\JoinColumn;
11
use Doctrine\ORM\Mapping\ManyToOne;
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 Stu\Component\Crew\CrewPositionEnum;
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\CrewSkillRepository;
17
18
#[Table(name: 'stu_crew_skill')]
19
#[Entity(repositoryClass: CrewSkillRepository::class)]
20
class CrewSkill implements CrewSkillInterface
21
{
22
    #[Id]
23
    #[Column(type: 'integer')]
24
    private int $crew_id;
25
26
    #[Id]
27
    #[Column(type: 'smallint', enumType: CrewPositionEnum::class)]
28
    private CrewPositionEnum $position;
29
30
    #[Column(type: 'integer')]
31
    private int $expertise = 0;
32
33
    #[ManyToOne(targetEntity: 'Crew')]
34
    #[JoinColumn(name: 'crew_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
35
    private CrewInterface $crew;
36
37 1
    #[Override]
38
    public function getPosition(): CrewPositionEnum
39
    {
40 1
        return $this->position;
41
    }
42
43
    #[Override]
44
    public function setPosition(CrewPositionEnum $position): CrewSkillInterface
45
    {
46
        $this->position = $position;
47
48
        return $this;
49
    }
50
51
    #[Override]
52
    public function getCrew(): CrewInterface
53
    {
54
        return $this->crew;
55
    }
56
57
    #[Override]
58
    public function setCrew(CrewInterface $crew): CrewSkillInterface
59
    {
60
        $this->crew = $crew;
61
        $this->crew_id = $crew->getId();
62
63
        return $this;
64
    }
65
66
    #[Override]
67
    public function increaseExpertise(int $amount): void
68
    {
69
        $this->expertise += $amount;
70
    }
71
72 1
    #[Override]
73
    public function getExpertise(): int
74
    {
75 1
        return $this->expertise;
76
    }
77
78 1
    #[Override]
79
    public function getRank(): CrewSkillLevelEnum
80
    {
81 1
        return CrewSkillLevelEnum::getForExpertise($this->expertise);
82
    }
83
}
84