/** * Get the response status from the payload. * * @param PayloadInterface $payload * * @return integer */ public function status(PayloadInterface $payload) { $status = $payload->getStatus(); if ($status >= PayloadInterface::OK && $status < PayloadInterface::ERROR) { return 200; } if ($status >= PayloadInterface::ERROR && $status < PayloadInterface::INVALID) { return 500; } if ($status >= PayloadInterface::INVALID && $status < PayloadInterface::UNKNOWN) { return 400; } return 520; }
/** * Get the response with the status code from the payload. * * @param ResponseInterface $response * @param PayloadInterface $payload * * @return ResponseInterface */ private function status(ResponseInterface $response, PayloadInterface $payload) { $status = $payload->getStatus(); $code = $this->http_status->getStatusCode($status); return $response->withStatus($code); }