status = $status; $this->body = $body; $this->errorKind = $errorKind; } public function getStatus(): int { return $this->status; } /** @return mixed */ public function getBody() { return $this->body; } public function getErrorKind(): ?string { return $this->errorKind; } /** * Build the most specific OpenWAApiException subclass for a status code. * * @param mixed $body */ public static function classify(int $status, string $message, $body, ?string $errorKind): OpenWAApiException { return match ($status) { 401 => new OpenWAAuthException($message, $status, $body, $errorKind), 403 => new OpenWAForbiddenException($message, $status, $body, $errorKind), 404 => new OpenWANotFoundException($message, $status, $body, $errorKind), 409 => new OpenWAConflictException($message, $status, $body, $errorKind), 429 => new OpenWARateLimitException($message, $status, $body, $errorKind), 501 => new OpenWANotImplementedException($message, $status, $body, $errorKind), default => new OpenWAApiException($message, $status, $body, $errorKind), }; } }