Passed
Push — master ( 66afc8...ff3c83 )
by Janko
09:01
created

ShipRumpCategoryRoleCrew::getJob1Crew()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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\Index;
12
use Doctrine\ORM\Mapping\JoinColumn;
13
use Doctrine\ORM\Mapping\ManyToOne;
14
use Doctrine\ORM\Mapping\Table;
15
use Stu\Component\Crew\CrewTypeEnum;
16
use Stu\Component\Spacecraft\SpacecraftRumpRoleEnum;
17
use Stu\Orm\Repository\ShipRumpCategoryRoleCrewRepository;
18
19
#[Table(name: 'stu_rumps_cat_role_crew')]
20
#[Index(name: 'ship_rump_category_role_idx', columns: ['rump_category_id', 'rump_role_id'])]
21
#[Entity(repositoryClass: ShipRumpCategoryRoleCrewRepository::class)]
22
class ShipRumpCategoryRoleCrew
23
{
24
    #[Id]
25
    #[Column(type: 'integer')]
26
    #[GeneratedValue(strategy: 'IDENTITY')]
27
    private int $id;
28
29
    #[Column(type: 'integer')]
30
    private int $rump_category_id = 0;
31
32
    #[Column(type: 'integer', enumType: SpacecraftRumpRoleEnum::class)]
33
    private SpacecraftRumpRoleEnum $rump_role_id;
34
35
    #[Column(type: 'smallint')]
36
    private int $job_1_crew = 0;
37
38
    #[Column(type: 'smallint')]
39
    private int $job_2_crew = 0;
40
41
    #[Column(type: 'smallint')]
42
    private int $job_3_crew = 0;
43
44
    #[Column(type: 'smallint')]
45
    private int $job_4_crew = 0;
46
47
    #[Column(type: 'smallint')]
48
    private int $job_5_crew = 0;
49
50
    #[Column(type: 'smallint')]
51
    private int $job_6_crew = 0;
52
53
    #[Column(type: 'smallint')]
54
    private int $job_7_crew = 0;
55
56
    #[ManyToOne(targetEntity: ShipRumpRole::class)]
57
    #[JoinColumn(name: 'rump_role_id', nullable: false, referencedColumnName: 'id', onDelete: 'CASCADE')]
58
    private ShipRumpRole $shiprumpRole;
0 ignored issues
show
introduced by
The private property $shiprumpRole is not used, and could be removed.
Loading history...
59
60
    public function getId(): int
61
    {
62
        return $this->id;
63
    }
64
65
    public function getShipRumpCategoryId(): int
66
    {
67
        return $this->rump_category_id;
68
    }
69
70
    public function getShipRumpRoleId(): SpacecraftRumpRoleEnum
71
    {
72
        return $this->rump_role_id;
73
    }
74
75 11
    public function getCrewForPosition(CrewTypeEnum $type): int
76
    {
77
        return match ($type) {
78 11
            CrewTypeEnum::COMMAND => $this->job_1_crew,
79 11
            CrewTypeEnum::SECURITY => $this->job_2_crew,
80 11
            CrewTypeEnum::SCIENCE => $this->job_3_crew,
81 11
            CrewTypeEnum::TECHNICAL => $this->job_4_crew,
82 11
            CrewTypeEnum::NAVIGATION => $this->job_5_crew,
83 11
            CrewTypeEnum::CREWMAN => $this->job_6_crew,
84 11
            CrewTypeEnum::CAPTAIN => $this->job_7_crew
85
        };
86
    }
87
88 2
    public function getCrewSumForPositionsExceptCrewman(): int
89
    {
90 2
        return $this->job_1_crew
91 2
            + $this->job_2_crew
92 2
            + $this->job_3_crew
93 2
            + $this->job_4_crew
94 2
            + $this->job_5_crew
95 2
            + $this->job_7_crew;
96
    }
97
}
98