error = $error; } public function error(): ?ValidationError { return $this->error; } public function isValid(): bool { return $this->error === null; } public function hasError(): bool { return $this->error !== null; } public function __toString(): string { if ($this->error) { return $this->error->message(); } return ''; } }