-
Notifications
You must be signed in to change notification settings - Fork 0
/
Department.php
44 lines (37 loc) · 1.03 KB
/
Department.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
class Department
{
private string $department_name;
private $employees_array;
public function __construct(string $department_name, Employee ...$employees_array)
{
$this->department_name = $department_name;
$this->employees_array = $employees_array;
}
//setters
public function setDepartmentName($department_name)
{
$this->department_name = $department_name;
}
//getters
public function getDepartmentName(): string
{
return $this->department_name;
}
public function getEmployeesCount(): int
{
return count($this->employees_array);
}
public function getTotalSalary(): int
{
$result = 0;
foreach ($this->employees_array as $employee) {
$result += $employee->getSalary();
}
return $result;
}
public function __toString(): string
{
return $this->department_name . " has " . $this->getEmployeesCount() . " employees and summary salary " . $this->getTotalSalary();
}
}