forked from jkapuscik2/design-patterns-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompanyEmployeeTeam.php
More file actions
44 lines (32 loc) · 1.09 KB
/
CompanyEmployeeTeam.php
File metadata and controls
44 lines (32 loc) · 1.09 KB
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
namespace Behavioral\Iterator;
use SplObjectStorage, IteratorAggregate, Countable;
class CompanyEmployeeTeam implements IteratorAggregate, Countable {
public $person;
private $subordinates;
public function __construct (Employee $person) {
$this->subordinates = new SplObjectStorage();
$this->person = $person;
}
public function addSubordinate (CompanyEmployeeTeam $subordinate): void {
$this->subordinates->attach($subordinate);
}
public function removeSubordinate (CompanyEmployeeTeam $subordinate): void {
$this->subordinates->detach($subordinate);
}
public function getSubordinates (): SplObjectStorage {
return $this->subordinates;
}
public function getIterator (): EmployeeTeamIterator {
return new EmployeeTeamIterator($this);
}
public function count (): int {
return count(new EmployeeTeamIterator($this));
}
public function getName (): string {
return $this->person->name;
}
public function getPosition (): string {
return $this->person->position;
}
}