trait HasAliasesTrait (View source)

Add methods to classes at runtime.

Loosely based on spatie/macroable.

Methods

boolean
hasAlias(string $alias)

Get whether an alias is registered.

array|null
getAlias(string $alias)

Get a registered alias.

void
setAlias(array $alias)

Register an alias.

void
alias(string $alias, string|Closure $target, string $method = '')

Register an alias.

mixed
__call(string $method, array $parameters)

Call alias if registered.

mixed|null
resolve(string $key)

Resolve a dependency from the IoC container.

Details

boolean hasAlias(string $alias)

Get whether an alias is registered.

Parameters

string $alias

Return Value

boolean

array|null getAlias(string $alias)

Get a registered alias.

Parameters

string $alias

Return Value

array|null

void setAlias(array $alias)

Register an alias.

Useful when passed the return value of getAlias() to restore a previously registered alias, for example.

Parameters

array $alias mixed> $alias

Return Value

void

void alias(string $alias, string|Closure $target, string $method = '')

Register an alias.

Identical to setAlias but with a more user-friendly interface.

Parameters

string $alias
string|Closure $target
string $method

Return Value

void

mixed __call(string $method, array $parameters)

Call alias if registered.

Parameters

string $method
array $parameters

Return Value

mixed

abstract mixed|null resolve(string $key)

Resolve a dependency from the IoC container.

Parameters

string $key

Return Value

mixed|null