Skip to content

Instantly share code, notes, and snippets.

@mitchellvanw
Created March 6, 2014 13:13
Show Gist options
  • Save mitchellvanw/9389307 to your computer and use it in GitHub Desktop.
Save mitchellvanw/9389307 to your computer and use it in GitHub Desktop.
<?php class D{private $ls = [];public function dispatch($es){if(!is_array($es)){$this->f($es);}foreach($es as $e){$this->f($e);}}public function listenOn($n,$l){$this->al($n,$l);}private function f($e){$ls=$this->gl($e->getName());if(!$ls)return;foreach($ls as $l){$l->handle($e);}}private function gl($n){if(!$this->hl($n))return;return $this->ls[$n];}private function hl($n){return isset($this->l[$n]);}private function al($n,$l){$this->ls[$n][] = $l;}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment