Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2.  
  3. class E2 {
  4.     public function __construct(array $arguments = array()) {
  5.         if (!empty($arguments)) {
  6.             foreach ($arguments as $property => $argument) {
  7.                 $this->{$property} = $argument;
  8.             }
  9.         }
  10.     }
  11.  
  12.     public function __call($method, $arguments) {
  13.         $arguments = array_merge(array("E2" => $this), $arguments); // Note: method argument 0 will always referred to the main class ($this).
  14.         if (isset($this->{$method}) && is_callable($this->{$method})) {
  15.             return call_user_func_array($this->{$method}, $arguments);
  16.         } else {
  17.             throw new Exception("Fatal error: Call to undefined method E2 Object::{$method}()");
  18.         }
  19.     }
  20. }
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement