ClassesProvider

Provider

This abstract class implements the ServiceProviderInterface from Pimple. It provides functionality for managing callback registrations and offers a mechanism to access callbacks dynamically through the __get magic method.

Subclasses are expected to define their own service registration logic.

Properties

callbacks

protected array $callbacks

Methods

__get

Magic method to retrieve registered callbacks by their identifier.

public __get(string $property): callable|null

This method allows access to the registered callbacks using property syntax. If the requested property is found in the $callbacks array, it returns the corresponding callback; otherwise, it returns null.

Parameters:

ParameterTypeDescription
$propertystringThe identifier of the callback to retrieve.

Return Value:

The registered callback, or null if not found.


create_callback

Creates and registers a callback for a specific identifier.

protected create_callback(string $identifier, callable $callback): callable

This method ensures that a callback is not already registered under the same identifier. If the identifier is already in use, an exception is thrown. Otherwise, it adds the callback to the $callbacks array.

Parameters:

ParameterTypeDescription
$identifierstringThe unique identifier for the callback.
$callbackcallableThe callback function to register.

Return Value:

The registered callback.

Throws:

If the identifier is already in use.



Automatically generated on 2025-01-21