errors = $errors; } public function getErrors() { return $this->errors; } public function __toString() { return __CLASS__ . ": [{$this->code}]: {$this->message}\n" . $this->formatErrors(); } protected function formatErrors() { return implode("\n", array_map(function ($error) { return "- {$error}"; }, $this->errors)); } }