Guest User

Untitled

a guest
Jul 15th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. abstract class Entity {
  5.     protected $response = array();
  6.     protected $fields;
  7.     protected $table_name;
  8.  
  9.     abstract function __construct($table_name);
  10.  
  11.     function __set($name, $value) {
  12.         $this->{$name} = $value;
  13.     }
  14.  
  15.     function __get($name) {
  16.         if (array_key_exists($name, $this->response)) {
  17.             return $this->response[$name];
  18.         } else if (in_array($name, $this->response)) {
  19.             return null;
  20.         }
  21.         throw new Exception('Undefined object property ' . __CLASS__ . '::' . $name);
  22.     }
  23.  
  24.     public function fromRepsonse($response) {
  25.         $this->response = $response;
  26.     }
  27. }
Add Comment
Please, Sign In to add comment