/**
* @var string
*/
- protected $type = ICanCreateResponses::TYPE_HTML;
+ protected $type = self::TYPE_HTML;
/**
* {@inheritDoc}
*/
public function setType(string $type, ?string $content_type = null): void
{
- if (!in_array($type, ICanCreateResponses::ALLOWED_TYPES)) {
+ if (!in_array($type, static::ALLOWED_TYPES)) {
throw new InternalServerErrorException('wrong type');
}
case static::TYPE_XML:
$content_type = $content_type ?? 'text/xml';
break;
+ case static::TYPE_RSS:
+ $content_type = $content_type ?? 'application/rss+xml';
+ break;
+ case static::TYPE_ATOM:
+ $content_type = $content_type ?? 'application/atom+xml';
+ break;
}
-
$this->setHeader($content_type, 'Content-type');
$this->type = $type;
public function generate(): ResponseInterface
{
// Setting the response type as an X-header for direct usage
- $this->headers['X-RESPONSE-TYPE'] = $this->type;
+ $this->headers[static::X_HEADER] = $this->type;
return new \GuzzleHttp\Psr7\Response(200, $this->headers, $this->content);
}