Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 16 |
| iaSubject | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
210.00 | |
0.00% |
0 / 16 |
| get_iaSplSubjectTag | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| set_iaSplSubjectTag | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| get_iaSplSubjectEvent | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| set_iaSplSubjectEvent | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| attach | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 4 |
|||
| iaSplObserverQueueCmp | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 3 |
|||
| detach | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| notifyEvent | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 4 |
|||
| notify | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 3 |
|||
| <?php | |
| namespace ia\SubjectObserver; | |
| trait iaSubject { | |
| protected $iaSplSubjectTag = ''; | |
| protected $iaSplSubjectEvent = ''; | |
| protected $iaSplObserverQueue = []; | |
| public function get_iaSplSubjectTag() {return $this->iaSplSubjectTag;} | |
| public function set_iaSplSubjectTag($subjectTag) {$this->iaSplSubjectTag = $subjectTag;} | |
| public function get_iaSplSubjectEvent() {return $this->iaSplSubjectEvent;} | |
| public function set_iaSplSubjectEvent($subjectEvent) {$this->iaSplSubjectEvent = $subjectEvent;} | |
| public function attach(SplObserver $SplObserver) { | |
| $this->iaSplObserverQueue[spl_object_hash($SplObserver)] = [ count($this->iaSplObserverQueue), $SplObserver]; | |
| if(method_exists($SplObserver, 'get_iaSplObserverPriority')) { | |
| uasort($this->iaSplObserverQueue, array($this, 'iaSplObserverQueueCmp')); | |
| } | |
| } | |
| protected function iaSplObserverQueueCmp($a, $b) { | |
| if(method_exists($a[1], 'get_iaSplObserverPriority') && method_exists($b[1], 'get_iaSplObserverPriority') && $a[1]->get_iaSplObserverPriority() != $b[1]->get_iaSplObserverPriority()) { | |
| return $a[1]->get_iaSplObserverPriority() - $b[1]->get_iaSplObserverPriority(); | |
| } | |
| return $a[0] - $b[0]; | |
| } | |
| public function detach(SplObserver $SplObserver) { | |
| unset($this->iaSplObserverQueue[spl_object_hash($SplObserver)]); | |
| } | |
| public function notifyEvent($subjectEvent) { | |
| $this->set_iaSplSubjectEvent($subjectEvent); | |
| $this->notify(); | |
| $this->set_iaSplSubjectEvent(''); | |
| } | |
| public function notify() { | |
| foreach($this->iaSplObserverQueue as $notify) { | |
| $notify[1]->update($this); | |
| } | |
| } | |
| } | |