|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class Employee. |
|
5
|
|
|
* |
|
6
|
|
|
* Stores information about employee. |
|
7
|
|
|
*/ |
|
8
|
|
|
class Employee extends Man |
|
9
|
|
|
{ |
|
10
|
|
|
/** @var string employee's position */ |
|
11
|
|
|
private $position; |
|
12
|
|
|
/** @var IdCard employee's id card */ |
|
13
|
|
|
private $idCard; |
|
14
|
|
|
/** @var Room[] rooms */ |
|
15
|
|
|
private $room = []; |
|
16
|
|
|
/** @var Departament employee's departament */ |
|
17
|
|
|
private $departament; |
|
18
|
|
|
/** @var PastPosition[] past positions */ |
|
19
|
|
|
private $pastPosition = []; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Employee constructor. |
|
23
|
|
|
* |
|
24
|
|
|
* @param string $name name |
|
25
|
|
|
* @param string $surname second name |
|
26
|
|
|
* @param string $position employee's position |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct(string $name, string $surname, string $position) |
|
29
|
|
|
{ |
|
30
|
|
|
parent::__construct($name, $surname); |
|
31
|
|
|
$this->position = $position; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Deletes employee's room. |
|
36
|
|
|
* |
|
37
|
|
|
* @param Room $room room to delete |
|
38
|
|
|
*/ |
|
39
|
|
|
public function deleteRoom(Room $room): void |
|
40
|
|
|
{ |
|
41
|
|
|
unset($this->room[$room->getNumber()]); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Deletes past position. |
|
46
|
|
|
* |
|
47
|
|
|
* @param PastPosition $pastPosition position to delete |
|
48
|
|
|
*/ |
|
49
|
|
|
public function deletePastPosition(PastPosition $pastPosition): void |
|
50
|
|
|
{ |
|
51
|
|
|
unset($this->pastPosition[$pastPosition->getName()]); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Getter for position. |
|
56
|
|
|
* |
|
57
|
|
|
* @see Employee::$position |
|
58
|
|
|
* |
|
59
|
|
|
* @return string position |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getPosition(): string |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->position; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Getter for id card. |
|
68
|
|
|
* |
|
69
|
|
|
* @see Employee::$idCard |
|
70
|
|
|
* |
|
71
|
|
|
* @return IdCard id card |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getIdCard(): IdCard |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->idCard; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Getter for employee's rooms. |
|
80
|
|
|
* |
|
81
|
|
|
* @see Employee::$room |
|
82
|
|
|
* |
|
83
|
|
|
* @return Room[] rooms |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getRoom(): array |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->room; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Getter for employee's departament. |
|
92
|
|
|
* |
|
93
|
|
|
* @see Employee::$departament |
|
94
|
|
|
* |
|
95
|
|
|
* @return Departament current departament |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getDepartament(): Departament |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->departament; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Getter for past positions. |
|
104
|
|
|
* |
|
105
|
|
|
* @see Employee::$pastPosition |
|
106
|
|
|
* |
|
107
|
|
|
* @return PastPosition[] past positions |
|
108
|
|
|
*/ |
|
109
|
|
|
public function getPastPosition(): array |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->pastPosition; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Setter for position. |
|
117
|
|
|
* |
|
118
|
|
|
* @see Employee::$position |
|
119
|
|
|
* |
|
120
|
|
|
* @param string $position position to add |
|
121
|
|
|
*/ |
|
122
|
|
|
public function setPosition(string $position): void |
|
123
|
|
|
{ |
|
124
|
|
|
$this->setPastPosition(new PastPosition($this->position, $this->departament)); |
|
125
|
|
|
$this->position = $position; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Setter for id card. |
|
130
|
|
|
* |
|
131
|
|
|
* @see Employee::$idCard |
|
132
|
|
|
* |
|
133
|
|
|
* @param IdCard $card new id card |
|
134
|
|
|
*/ |
|
135
|
|
|
public function setIdCard(IdCard $card): void |
|
136
|
|
|
{ |
|
137
|
|
|
$this->idCard = $card; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Setter for room. |
|
142
|
|
|
* |
|
143
|
|
|
* @see Employee::$room |
|
144
|
|
|
* |
|
145
|
|
|
* @param Room $room new room |
|
146
|
|
|
*/ |
|
147
|
|
|
public function setRoom(Room $room): void |
|
148
|
|
|
{ |
|
149
|
|
|
$this->room[$room->getNumber()] = $room; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Setter for departament. |
|
154
|
|
|
* |
|
155
|
|
|
* @see Employee::$departament |
|
156
|
|
|
* |
|
157
|
|
|
* @param Departament $departament new departament |
|
158
|
|
|
*/ |
|
159
|
|
|
public function setDepartament(Departament $departament): void |
|
160
|
|
|
{ |
|
161
|
|
|
$this->departament = $departament; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* Setter for past position. |
|
166
|
|
|
* |
|
167
|
|
|
* @see Employee::$pastPosition |
|
168
|
|
|
* |
|
169
|
|
|
* @param PastPosition $pastPosition new position |
|
170
|
|
|
*/ |
|
171
|
|
|
public function setPastPosition(PastPosition $pastPosition): void |
|
172
|
|
|
{ |
|
173
|
|
|
$this->pastPosition[$pastPosition->getName()] = $pastPosition; |
|
174
|
|
|
} |
|
175
|
|
|
} |