diff --git a/lib/container.php b/lib/container.php index 686cec1..61b59cf 100644 --- a/lib/container.php +++ b/lib/container.php @@ -3,15 +3,29 @@ class Container extends Ghost { + protected static function called() + { + return actual('container.class', maker(get_called_class())); + } + public function __construct(array $values = []) { parent::__construct($values, 'container'); } + public function build($class, $args = [], $single = true) + { + if (!isset($this->$class) || !$single) { + $this->$class = maker($class, $args); + } + + return $this->$class; + } + public static function __callStatic($m, $a) { - $i = new static; + $i = static::called(); - return call_user_func_array(); + return call_user_func_array([$i, $m], $a); } } diff --git a/lib/inner.php b/lib/inner.php new file mode 100644 index 0000000..d5e072e --- /dev/null +++ b/lib/inner.php @@ -0,0 +1,4 @@ +