<?php class ErrorList { private array $errors; public function add (string $fieldName, ValidationError $validationError): void { $this->errors[$fieldName][] = $validationError; } public function getListOfFieldErrors (string $fieldName): array { $result = $this->errors[$fieldName] ?? null; if (!$result) { throw new ArrayNotExistsException("Массива под таким ключом не существует. "); } foreach ($result as $key => $error) { $result [$key] = $error->get("text"); } return $result; } public function isEmpty (): bool { return empty($this->errors); } }
You have javascript disabled. You will not be able to edit any code.