Chciałem przedstawić klasę prostego kontenera.
Wzorowałem się na kontenerze z laravela, lecz nie "kopiowałem", a pisałem samodzielnie, co na pewno widać

Chciałbym prosić o ocenę kodu, w miarę możliwości tego jak będzie wydajny oraz wytknięcie błędów.
Z góry dziękuję za waszą pomoc

class Container implements ArrayAccess { private $maxdepth = 10; // ================================================== // { if($bind = $this->getBinding($key)) { { { $bind['instance'] = $bind['closure'](); $this->instances[$key] = $bind['instance']; } else { $bind['instance'] = $bind['closure'](); } } return $bind['instance']; } else { if($ret != false) { $this->bind($key, $ret); } return $ret; } } public function bind($key, $value) { return $this->makeBinding($key, $value, false); } public function singleton($key, $value) { return $this->makeBinding($key, $value, true); } // ================================================== // { if($depth >= $this->maxdepth) { throw new OutOfBoundsException('Maximum depth of makeClassWithParams is '.$this->maxdepth); return false; } if(class_exists($name)) { $class = new ReflectionClass($name); $constructor = $class->getConstructor()->getParameters(); { $constructor = $class->getConstructor()->getParameters(); foreach($constructor as $classparam) { $classparam = $classparam->getClass(); { $params[] = null; } else { } } $class = $class->newInstanceArgs($params); } else { $class = $class->newInstanceArgs($params); } return $class; } else { return false; } } protected function makeBinding($key, $value, $singleton) { $this->clearBinding($key); $bind['instance'] = $key; if($value instanceof Closure) { $bind['closure'] = $value; $bind['singleton'] = (bool)$singleton; } else { $bind['instance'] = $value; } { $this->instances[$key] = $bind['instance']; } else { $this->instances[$key] = null; } $bind['instance'] = $key; $this->bindings[$key] = $bind; } protected function getBinding($key) { { $bind = $this->bindings[$key]; { $bind['instance'] = $this->instances[$key]; } return $bind; } return false; } protected function clearBinding($key) { } // ================================================== // public function offsetGet($key) { return $this->make($key); } public function offsetSet($key, $value) { $function = function() use ($value) { return $value; }; $this->bind($key, $function); } public function offsetExists($key) { } public function offsetUnset($key) { $this->clearBinding($key); } public function __set($key, $value) { $this[$key] = $value; } public function __get($key) { return $this[$key]; } }