> */ public array $errors = []; /** @var array */ public array $error_data = []; public function __construct(string $code = '', string $message = '', mixed $data = '') { if ('' !== $code) { $this->errors[$code][] = $message; if ('' !== $data) { $this->error_data[$code] = $data; } } } public function get_error_code(): string { return (string) (array_key_first($this->errors) ?? ''); } public function get_error_message(): string { $code = $this->get_error_code(); return '' !== $code ? ($this->errors[$code][0] ?? '') : ''; } } }