CrewTraining::setUser()   A
last analyzed

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 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\Index;
12
use Doctrine\ORM\Mapping\JoinColumn;
13
use Doctrine\ORM\Mapping\ManyToOne;
14
use Doctrine\ORM\Mapping\Table;
15
use Stu\Orm\Repository\CrewTrainingRepository;
16
17
#[Table(name: 'stu_crew_training')]
18
#[Index(name: 'crew_training_colony_idx', columns: ['colony_id'])]
19
#[Index(name: 'crew_training_user_idx', columns: ['user_id'])]
20
#[Entity(repositoryClass: CrewTrainingRepository::class)]
21
class CrewTraining
22
{
23
    #[Id]
24
    #[Column(type: 'integer')]
25
    #[GeneratedValue(strategy: 'IDENTITY')]
26
    private int $id;
27
28
    #[Column(type: 'integer')]
29
    private int $user_id = 0;
30
31
    #[Column(type: 'integer')]
32
    private int $colony_id = 0;
33
34
    #[ManyToOne(targetEntity: Colony::class)]
35
    #[JoinColumn(name: 'colony_id', nullable: false, referencedColumnName: 'id')]
36
    private Colony $colony;
37
38
    #[ManyToOne(targetEntity: User::class)]
39
    #[JoinColumn(name: 'user_id', nullable: false, referencedColumnName: 'id', onDelete: 'CASCADE')]
40
    private User $user;
41
42
    public function getId(): int
43
    {
44
        return $this->id;
45
    }
46
47
    public function getUserId(): int
48
    {
49
        return $this->user_id;
50
    }
51
52
    public function getColonyId(): int
53
    {
54
        return $this->colony_id;
55
    }
56
57
    public function getUser(): User
58
    {
59
        return $this->user;
60
    }
61
62
    public function setUser(User $user): CrewTraining
63
    {
64
        $this->user = $user;
65
        return $this;
66
    }
67
68
    public function getColony(): Colony
69
    {
70
        return $this->colony;
71
    }
72
73
    public function setColony(Colony $colony): CrewTraining
74
    {
75
        $this->colony = $colony;
76
        return $this;
77
    }
78
}
79