*/ trait ResponseDecoratorTrait { use MessageDecoratorTrait { getMessage as private; } /** * Returns the decorated response. * * Since the underlying Response is immutable as well * exposing it is not an issue, because it's state cannot be altered * * @return ResponseInterface */ public function getResponse(): ResponseInterface { /** @var ResponseInterface $message */ $message = $this->getMessage(); return $message; } /** * Exchanges the underlying response with another. * * @param ResponseInterface $response * * @return self */ public function withResponse(ResponseInterface $response): self { $new = clone $this; $new->message = $response; return $new; } /** * {@inheritdoc} */ public function getStatusCode(): int { return $this->getResponse()->getStatusCode(); } /** * {@inheritdoc} */ public function withStatus($code, $reasonPhrase = ''): self { $new = clone $this; $new->message = $this->getResponse()->withStatus($code, $reasonPhrase); return $new; } /** * {@inheritdoc} */ public function getReasonPhrase(): string { return $this->getResponse()->getReasonPhrase(); } }