ObjectDefinition class

class Slick\Di\Definition\ObjectDefinition

An object instantiation definition that wraps the necessary steps so that a dependency container can instantiate a given class.

__construct($className)

Creates a definition for provided class name.

Parameters:
  • $className (string) – The class name that will be instantiated.
static create($className)

Factory method to create an object definition.

Parameters:
  • $className (string) – The class name that will be instantiated.
Returns:

ObjectDefinition definition object

with(...$arguments)

Set the arguments for the last defined method call. If no method call was defined yet it will set the constructor argument list

Parameters:
  • $arguments (array) – Arguments passed to object constructor
Returns:

The object definition itself. Useful for other method calls.

withConstructorArgument(...$arguments)

Set the arguments used to create the object.

Parameters:
  • $arguments (array) – Arguments passed to object constructor.
Returns:

The object definition itself. Useful for other method calls.

call($methodName)

Define a method call in the freshly created object.

Parameters:
  • $methodName (string) – The method name to call.
Returns:

The object definition itself. Useful for other method calls.

assign($value)

Set the value that will be assigned to a property.

Parameters:
  • $value (mixed) – The value to be assigned.
Returns:

The object definition itself. Useful for other method calls.

to($propertyName)

Assign the last defined value to the provided property. The value will be reset after its assigned.

Parameters:
  • $property (string) – The property name where last value will be assigned.
Returns:

The object definition itself. Useful for other method calls.

callMethod($methodName, ...$arguments)

Define a method call to the method with provided name.

Parameters:
  • $methodName (string) – The method name to call.
  • $arguments (array) – The list of arguments to use when calling the method.
Throws:

Slick\Exception\MethodNotFoundException if called method does not exists.

Returns:

The object definition itself. Useful for other method calls.

assignProperty($name, $value)

Assigns a value to the property with provided name.

Parameters:
  • $name (string) – The property name.
  • $value (mixed) – The value to assign to the property.
Returns:

The object definition itself. Useful for other method calls.

resolve()

Resolves the definition into an object.

Returns:The object as described in the definition