errors[] = $error; } /** * Get collected errors. * * @return Error[] */ public function getErrors(): array { return $this->errors; } /** * Check whether there are any errors. */ public function hasErrors(): bool { return !empty($this->errors); } /** * Reset/clear collected errors. */ public function clearErrors(): void { $this->errors = []; } }