Advertisement
NFL

Untitled

NFL
Apr 19th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. // класс - механизм наследования
  2. abstract class Inheritance {
  3.  
  4.     private $_inheritances = array();
  5.  
  6.     public function __call($method, array $arguments = array()) {
  7.         // тут будем перехватывать вызовы методов
  8.         foreach ($this->_inheritances as $inheritance) {
  9.             $inheritance->invoke($method, $arguments);
  10.         }
  11.     }
  12.  
  13.     public function invoke($method, $arguments) {
  14.         if (is_callable(array($this, $method))) {
  15.             return call_user_func_array(array($this, $method), $arguments);
  16.         }
  17.     }
  18.  
  19.     protected function addInheritance(Inheritance $inheritance) {
  20.         $this->_inheritances[get_class($inheritance)] = $inheritance;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement