-
Notifications
You must be signed in to change notification settings - Fork 0
CompositeErrorReporter
Aggregates multiple error reporters and delegates error reporting to all of them.
This class MUST be used when you want to ensure that all registered reporters are notified of an error. If any reporter throws an exception, this class SHALL log the failure using error_log and MUST continue reporting to the remaining reporters.
- Full name:
\FastForward\Defer\ErrorReporter\CompositeErrorReporter - This class is marked as final and can't be subclassed
- This class implements:
\FastForward\Defer\ErrorReporterInterface,Countable - This class is a Final class
Constructs a new CompositeErrorReporter instance.
public __construct(\FastForward\Defer\ErrorReporterInterface $reporters): mixedThis constructor SHALL accept any number of ErrorReporterInterface implementations. The reporters MUST be stored in the order provided.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$reporters |
\FastForward\Defer\ErrorReporterInterface | One or more error reporters to aggregate. |
Reports a throwable to all registered reporters.
public report(\Throwable $throwable, callable|null $callback = null, array $args = []): voidThis method MUST attempt to report the throwable to each reporter in sequence. If a reporter throws an exception, the failure MUST be logged using error_log, and reporting SHALL continue for the remaining reporters.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$throwable |
\Throwable | the exception or error to report |
$callback |
callable|null | the related callback, if available |
$args |
array | arguments passed to the callback, if any |
Adds a new reporter to the composite.
public add(\FastForward\Defer\ErrorReporterInterface $reporter): selfThis method MUST append the reporter to the internal list. The reporter MUST implement ErrorReporterInterface.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$reporter |
\FastForward\Defer\ErrorReporterInterface | the reporter to add |
Return Value:
returns the current instance for chaining
Determines if the composite contains no reporters.
public isEmpty(): boolThis method MUST return true if no reporters are registered, and false otherwise.
Return Value:
true if no reporters are registered; otherwise, false
Returns the number of registered reporters.
public count(): intThis method MUST return the count of reporters currently registered in the composite.
Return Value:
the number of reporters