$injector= new Injector(Bindings::using()
->singleton(Signing::class) // Binds a single Signing instance to Singing
->singleton(Algorithm::class, SHA256::class) // Binds a single SHA256 instance to Algorithm
->singleton(Storage::class, new InFileSystem('.')) // 🆕 Always returns the instance passed
);
While the upper two provide lazily instantiated singletons, this new functionality offers an eager version.
Extends https://github.com/xp-forge/inject/pull/23 and adds the possibility to pass instances to the
singleton()
method.While the upper two provide lazily instantiated singletons, this new functionality offers an eager version.