Aggregates multiple error reporters and delegates error reporting to all of them.
Description
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.
Interfaces
This interface MUST be implemented by any class that reports exceptions from deferred callbacks.
Properties
List of error reporters. This property MUST contain only valid ErrorReporterInterface implementations.
Methods
Constructs a new CompositeErrorReporter instance.
Adds a new reporter to the composite.
Returns the number of registered reporters.
Determines if the composite contains no reporters.
Reports a throwable to all registered reporters.
List of error reporters. This property MUST contain only valid ErrorReporterInterface implementations.
private
array<string|int, ErrorReporterInterface>
$reporters
Constructs a new CompositeErrorReporter instance.
public
__construct(ErrorReporterInterface
...$reporters) : mixed
Description
This constructor SHALL accept any number of ErrorReporterInterface implementations. The reporters MUST be stored in the order provided.
Parameters
Description
One or more error reporters to aggregate.
Adds a new reporter to the composite.
public
add(ErrorReporterInterface
$reporter) : self
Description
This method MUST append the reporter to the internal list. The reporter MUST implement ErrorReporterInterface.
Parameters
Description
the reporter to add
Return values
Description
returns the current instance for chaining
Returns the number of registered reporters.
public
count() : int
Description
This method MUST return the count of reporters currently registered in the composite.
Return values
Description
the number of reporters
Determines if the composite contains no reporters.
public
isEmpty() : bool
Description
This method MUST return true if no reporters are registered, and false otherwise.
Return values
Description
true if no reporters are registered; otherwise, false
Reports a throwable to all registered reporters.
public
report(Throwable
$throwable[,
callable|null
$callback = null][,
array<string|int, mixed>
$args = []]) : void
Description
This 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
$throwable
:
Throwable
Description
the exception or error to report
$callback
:
callable|null
=
null
Description
the related callback, if available
$args
:
array<string|int, mixed>
=
[]
Description
arguments passed to the callback, if any