Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class FooBase{
- public function __get($name){
- $getter = 'get'.ucfirst($name);
- if(method_exists($this, $getter)) return $this->$getter();
- throw new Exception("Property {$getter} is not defined.");
- }
- public function __set($name, $value){
- $setter = 'set'.ucfirst($name);
- if(method_exists($this, $setter)) return $this->$setter($value);
- throw new Exception("Property {$setter} is not defined.");
- }
- public function __call($name, $arguments){
- $caller = 'call'.ucfirst($name);
- if(method_exists($this, $caller)) return $this->$caller($arguments);
- throw new Exception("Property {$caller} is not defined.");
- }
- }
- class Foo extends FooBase{
- static $instance;
- private $data;
- private static
- $yql = 'https://query.yahooapis.com/v1/public/yql?q=';
- public static function app(){
- if(!(self::$instance instanceof self)){
- self::$instance = new self();
- self::app()->data = 'somedata';
- // ...
- }
- return self::$instance;
- }
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement