Skip to content

final class Collection

Source Code

Collection of Error objects.

NamespaceBeastBytes\CodPhp\Error
Inheritance

BeastBytes\CodPhp\Error\Collection

Methods

addError()

Add an error to the collection.

public static function addError(string $message, BeastBytes\CodPhp\Element\Element $element, array $context = []): BeastBytes\CodPhp\Error\Error
$messagestringError message.
$elementBeastBytes\CodPhp\Element\ElementElement causing the error.
$contextarrayAdditional information about the error.
returnBeastBytes\CodPhp\Error\Error

Declared in BeastBytes\CodPhp\Error\Collection


addNotice()

Add a notice to the collection.

public static function addNotice(string $message, BeastBytes\CodPhp\Element\Element $element, array $context = []): BeastBytes\CodPhp\Error\Error
$messagestringError message.
$elementBeastBytes\CodPhp\Element\ElementElement causing the error.
$contextarrayAdditional information about the error.
returnBeastBytes\CodPhp\Error\Error

Declared in BeastBytes\CodPhp\Error\Collection


addWarning()

Add a warning to the collection.

public static function addWarning(string $message, BeastBytes\CodPhp\Element\Element $element, array $context = []): BeastBytes\CodPhp\Error\Error
$messagestringError message.
$elementBeastBytes\CodPhp\Element\ElementElement causing the error.
$contextarrayAdditional information about the error.
returnBeastBytes\CodPhp\Error\Error

Declared in BeastBytes\CodPhp\Error\Collection


asJson()

Returns a collection of errors as a JSON object.

public static function asJson(): string
returnstring
throwsJsonException

Declared in BeastBytes\CodPhp\Error\Collection


getErrors()

Returns an array of Error objects.

The array is either an array of Error objects at the specified level, or an array of arrays of Error objects index by error level.

public static function getErrors(BeastBytes\CodPhp\Error\ErrorLevel|null $level = null): array
$levelBeastBytes\CodPhp\Error\ErrorLevel|nullError level to return, or all error levels if `null`.
returnarrayErrors in the collection, either at the specified error level, or indexed by error level

Declared in BeastBytes\CodPhp\Error\Collection


hasErrors()

Returns a boolean indicating whether the collection contains errors.

Reports on a particular error level if $level is an ErrorLevel, or all error levels if $level === null.

public static function hasErrors(BeastBytes\CodPhp\Error\ErrorLevel|null $level = null): bool
$levelBeastBytes\CodPhp\Error\ErrorLevel|nullThe error level to report, or all error levels if `null`.
returnboolWhether the collection has errors at the specified error level.

Declared in BeastBytes\CodPhp\Error\Collection


Generated by CodPhp