Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- abstract class PoolObject
- {
- static public function PoolConstructor($type, ...$params)
- {
- return new $type(...$params);
- }
- }
- // pool server
- class Pool
- {
- private $pool = array();
- public function getObject($type, $reference, ...$params)
- {
- if(!isset($this->pool[$type][$reference]))
- $this->pool[$type][$reference] = $type::PoolConstructor($type, ...$params);
- return $this->pool[$type][$reference];
- }
- }
- class ejemplo extends PoolObject
- {
- private $ejemplo = null;
- public function __construct($hola)
- {
- echo $hola;
- }
- }
- $pool = new Pool();
- $hola = 'hola brother';
- $instanceOfEjemplo = $pool->getObject('ejemplo', 1, $hola);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement