1class Test {
2
3 protected $listeners;
4
5 public function __construct() {
6 $this->listeners = array();
7 }
8
9 private function a() {
10 echo 'something';
11 }
12
13 private function b() {
14 echo 'something else';
15 }
16
17 public function __call($fname, $args) {
18 call_user_func_array(array($this, $fname), $args);
19 foreach($this->listeners as $listener) {
20 $listener->notify('fname was called');
21 }
22 }
23
24 public function addListener(Listener $listener) {
25 $this->listeners[]= $listener;
26 }
27}