getMessages(), $prev); } public static function fromArray(array $invalidData, ?Throwable $prev = null): self { $status = StatusCodeInterface::STATUS_BAD_REQUEST; $e = new self('Provided data is not valid', $status, $prev); $e->detail = $e->getMessage(); $e->title = self::TITLE; $e->type = toProblemDetailsType(self::ERROR_CODE); $e->status = StatusCodeInterface::STATUS_BAD_REQUEST; $e->invalidElements = $invalidData; $e->additional = ['invalidElements' => array_keys($invalidData)]; // TODO Expose reasons for the validation to fail // $e->additional = ['invalidElements' => array_keys($invalidData), 'reasons' => $invalidData]; return $e; } public function getInvalidElements(): array { return $this->invalidElements; } public function __toString(): string { return sprintf( '%s %s in %s:%s%s%s%sStack trace:%s%s', __CLASS__, $this->getMessage(), $this->getFile(), $this->getLine(), PHP_EOL, arrayToString($this->getInvalidElements()), PHP_EOL, PHP_EOL, $this->getTraceAsString(), ); } }