trait Registry (View source)

This trait provides a mechanism to manage a collection of items within a class.

Ensures the collection is initialized and accessible, allowing items to be added, retrieved, checked for existence, and removed.

Methods:

  • ensureCollectionExists(): array: Ensures the collection property exists and is initialized.
  • initializeCollection(): void: Initializes the collection property if it does not exist.
  • add(mixed $object, string|null $name): void: Adds an item to the collection.
  • get(string $name): mixed: Retrieves an item from the collection by name.
  • contains(string $name): bool: Checks if an item exists in the collection.
  • remove(string $name): void: Removes an item from the collection by name.

Methods

void
add(mixed $object, string $name = null)

Adds an item to the registry.

mixed
get(string $name)

Gets an item from the registry.

bool
contains(string $name)

Checks if an item exists in the registry.

void
remove(string $name)

Removes an item from the registry.

Details

void add(mixed $object, string $name = null)

Adds an item to the registry.

Parameters

mixed $object
string $name

Return Value

void

Exceptions

ReflectionException

mixed get(string $name)

Gets an item from the registry.

Parameters

string $name

Return Value

mixed

Exceptions

ReflectionException

bool contains(string $name)

Checks if an item exists in the registry.

Parameters

string $name

Return Value

bool

Exceptions

ReflectionException

void remove(string $name)

Removes an item from the registry.

Parameters

string $name

Return Value

void

Exceptions

ReflectionException