agent foundation
This commit is contained in:
@@ -4,6 +4,8 @@ namespace MintyPHP\App;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
// Minimal DI container: factories are registered with set() and resolved lazily on first get().
|
||||
// Each service is instantiated at most once — get() returns the same instance on every call.
|
||||
final class AppContainer
|
||||
{
|
||||
/** @var array<string, callable(self): mixed> */
|
||||
@@ -32,6 +34,7 @@ final class AppContainer
|
||||
throw new RuntimeException('Service not bound: ' . $id);
|
||||
}
|
||||
|
||||
// Resolve, cache, and return — factory receives the container for its own dependencies.
|
||||
$this->instances[$id] = ($this->bindings[$id])($this);
|
||||
return $this->instances[$id];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user