Revision: 54910
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 17, 2012 19:55 by Knarf
Initial Code
/* * A class i started to implement, which ended up in a working concept * However I'm not sure if it's a legal way of programming since I unnessesery * changes the structure of php without some real value except nicer structure * * For now it remain a concept * * Usage: * * concept::create()->create1(); * concept::create()->create2(); * concept::test()->test1(); * concept::test()->test2(); * */ class concept { private static $functions = array( 'create' => '__callStatic', 'create1' => 'create', 'create2' => 'create', 'test' => '__callStatic', 'test1' => 'test', 'test2' => 'test'); private $create = false; private function create1() { \pre::dump('create1'); } private function create2() { \pre::dump('create2'); } private function test1() { \pre::dump('test1'); } private function test2() { \pre::dump('test2'); } public static function __callStatic($name, $argument) { if(isset(self::$functions[$name]) && self::$functions[$name] == '__callStatic') { $className = __class__; $new = new $className; $new->$name = true; return $new; } else { throw new \Exception('Static function in class <b>sql</b> does not exists; ' . $name); } } public function __call($name, $argument) { $function = isset(self::$functions[$name]) ? self::$functions[$name] : null; $call = array($this, $name); if(isset($this->$function) && $this->$function === true && is_callable($call)) { call_user_func_array($call, $argument); } else { throw new \Exception('Function in class <b>sql</b> does not exists; ' . $name); } } }
Initial URL
Initial Description
A class i started to implement, which ended up in a working concept However I'm not sure if it's a legal way of programming since I unnessesery changes the structure of php without some real value except nicer structure For now it remain a concept Usage: concept::create()->create1(); concept::create()->create2(); concept::test()->test1(); concept::test()->test2();
Initial Title
concept: php multidimentional methods
Initial Tags
class, php, object
Initial Language
PHP