1 | <?php |
||
7 | class SubjectList |
||
8 | { |
||
9 | /** |
||
10 | * @const ERR_SUBJECT_NAME_NOT_EXIST Exception code if a subject name is |
||
11 | * not found. |
||
12 | */ |
||
13 | const ERR_SUBJECT_NAME_NOT_EXIST = 1317001; |
||
14 | |||
15 | /** |
||
16 | * @const ERR_SUBJECT_NOT_FOUND Exception code if a subject is not found. |
||
17 | */ |
||
18 | const ERR_SUBJECT_NOT_FOUND = 1317002; |
||
19 | |||
20 | /** |
||
21 | * @var \SplSubject[] $subjectList List of all subjects declared |
||
22 | */ |
||
23 | protected $subjectList = []; |
||
24 | |||
25 | /** |
||
26 | * Getter accessor to property subjectList |
||
27 | * |
||
28 | * @return \SplSubject[] |
||
29 | */ |
||
30 | public function getSubjectList() |
||
34 | |||
35 | /** |
||
36 | * Obtain a subject object with this name |
||
37 | * |
||
38 | * @param string $subjectName The name of the subject object |
||
39 | * |
||
40 | * @return \SplSubject |
||
41 | * |
||
42 | * @throws Exception If the subject name not exist |
||
43 | */ |
||
44 | public function getSubjectForName($subjectName) |
||
55 | |||
56 | |||
57 | /** |
||
58 | * Add a new subject to the list |
||
59 | * |
||
60 | * @param \SplSubject $subject The new subject to add |
||
61 | * @param string|null $subjectName (default null) The subject name, if null, |
||
62 | * the name of the class will be used |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function addSubject(\SplSubject $subject, $subjectName = null) |
||
76 | |||
77 | /** |
||
78 | * Remove a subject from the list |
||
79 | * |
||
80 | * @param \SplSubject $subject The subject to remove from the list |
||
81 | * |
||
82 | * @return $this |
||
83 | * |
||
84 | * @throws Exception If the subject has not been found into the list |
||
85 | */ |
||
86 | public function removeSubject(\SplSubject $subject) |
||
101 | } |
||
102 |