class InjectionCreator implements Factory (View source)

A class for creating new objects by the injector.

Methods

public
object
create(string|object $class, array $params = [])

Create a new instance of a class

Details

object create(string|object $class, array $params = [])

Create a new instance of a class

Passing an object for $class will result from using an anonymous class in unit testing, e.g. Injector::inst()->load([SomeClass::class => ['class' => new class { ... }]]);

Parameters

string|object $class
  • string: The FQCN of the class, object: A class instance
array $params

The constructor parameters.

Return Value

object

The created service instances.