abschluss
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace Blog\Core;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Container {
|
||||
private array $instances = [];
|
||||
|
||||
public function set(string $key, callable $factory): void {
|
||||
$this->instances[$key] = $factory;
|
||||
}
|
||||
|
||||
public function get(string $key): mixed {
|
||||
if(!isset($this->instances[$key])) {
|
||||
throw new Exception("No instance found for {$key}");
|
||||
}
|
||||
return $this->instances[$key]($this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user