Skip to content

ValidationReportQuery

ValidationReportQuery allows queries against the validation run report.

class ValidationReportQuery implements IValidationReportQuery

ImplementsIValidationReportQuery
Since1.0.0
SourceValidator/ValidationReportQuery.php

public function __construct(ValidationReport $report): mixed

Constructor.

The validation report instance.

ParameterTypeDescription
$reportValidationReportThe validation report instance.

Returns mixed

MethodDescription
[`byArgument(ValidationArgumentstring
[`byErrorName(stringarray<int, string> $name): IValidationReportQuery`](#byerrorname)
byMaxSeverity(int $maxSeverity): IValidationReportQueryReturns a new IValidationReportQuery which contains only the incidents of the given severity or lower (and the other existing filter rules).
byMinSeverity(int $minSeverity): IValidationReportQueryReturns a new IValidationReportQuery which contains only the incidents of the given severity or higher (and the other existing filter rules).
[`byValidator(stringarray<int, string> $name): IValidationReportQuery`](#byvalidator)
count(): intGet the number of incidents matching the currently defined filter rules.
getArguments(): array<int, ValidationArgument>Retrieves all ValidationArgument objects which match the currently defined filter rules.
getErrorMessages(): array<int, string>Retrieves all error messages which match the currently defined filter rules.
getErrorMessagesWithFields(): array<int, array{message: string, errors: array<int, string>}>Retrieves all error messages together with the fields that caused them, matching the currently defined filter rules.
getErrors(): array<int, ValidationError>Retrieves all ValidationError objects which match the currently defined filter rules.
getIncidents(): array<int, ValidationIncident>Retrieves all incidents which match the currently defined filter rules.
getResult(): ?intRetrieves the highest validation result code of the collection composed of the currently defined filter rules.
has(): boolCheck if there are any incidents matching the currently defined filter rules.

public function byArgument(ValidationArgument|string|array<int, ValidationArgument|string> $argument): IValidationReportQuery

Returns a new IValidationReportQuery which returns only the incidents for the given argument (and the other existing filter rules).

The argument instance, or a parameter name, or an array of these elements.

ParameterTypeDescription
$argumentValidationArgument`string

Returns IValidationReportQuery

public function byErrorName(string|array<int, string> $name): IValidationReportQuery

Returns a new IValidationReportQuery which contains only the incidents for the given error name (and the other existing filter rules).

The name of the error, or an array of names.

ParameterTypeDescription
$name`string“array<int, string>`

Returns IValidationReportQuery

public function byMaxSeverity(int $maxSeverity): IValidationReportQuery

Returns a new IValidationReportQuery which contains only the incidents of the given severity or lower (and the other existing filter rules).

The maximum severity.

ParameterTypeDescription
$maxSeverityintThe maximum severity.

Returns IValidationReportQuery

public function byMinSeverity(int $minSeverity): IValidationReportQuery

Returns a new IValidationReportQuery which contains only the incidents of the given severity or higher (and the other existing filter rules).

The minimum severity.

ParameterTypeDescription
$minSeverityintThe minimum severity.

Returns IValidationReportQuery

public function byValidator(string|array<int, string> $name): IValidationReportQuery

Returns a new IValidationReportQuery which contains only the incidents for the given validator (and the other existing filter rules).

The name of the validator, or an array of names.

ParameterTypeDescription
$name`string“array<int, string>`

Returns IValidationReportQuery

public function count(): int

Get the number of incidents matching the currently defined filter rules.

Returns int — The number of incidents matching the currently defined filter rules.

public function getArguments(): array<int, ValidationArgument>

Retrieves all ValidationArgument objects which match the currently defined filter rules.

Returns array``<``int``, ValidationArgument> — An array of ValidationArgument objects.

public function getErrorMessages(): array<int, string>

Retrieves all error messages which match the currently defined filter rules.

Returns array``<``int``, ``string``> — An array of message strings.

public function getErrorMessagesWithFields(): array<int, array{message: string, errors: array<int, string>}>

Retrieves all error messages together with the fields that caused them, matching the currently defined filter rules.

Returns the same array(‘message’ => string, ‘errors’ => array) structure as the deprecated ValidationManager::getErrorMessages(), but as a non-deprecated report-query accessor.

Returns array``<``int``, ``array{message: string, errors: array<int, string>}``> — An array of array(‘message’ => string, ‘errors’ => array).

public function getErrors(): array<int, ValidationError>

Retrieves all ValidationError objects which match the currently defined filter rules.

Returns array``<``int``, ValidationError> — An array of ValidationError objects.

public function getIncidents(): array<int, ValidationIncident>

Retrieves all incidents which match the currently defined filter rules.

Returns array``<``int``, ValidationIncident> — An array of ValidationIncident objects.

public function getResult(): ?int

Retrieves the highest validation result code of the collection composed of the currently defined filter rules.

Returns ?``int — An Validator::* severity constant, or null if there is no result for this filter combination. Please remember to do a strict === comparison if you are comparing against Validator::SUCCESS.

public function has(): bool

Check if there are any incidents matching the currently defined filter rules.

Returns bool — Whether or not any incidents exist for the currently defined filter rules.