mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[FormatAbstract] Check content type before sending header
This commit is contained in:
parent
1c17ffb5c4
commit
dbffbd4d4e
@ -21,8 +21,8 @@ abstract class FormatAbstract implements FormatInterface {
|
|||||||
/** The default charset (UTF-8) */
|
/** The default charset (UTF-8) */
|
||||||
const DEFAULT_CHARSET = 'UTF-8';
|
const DEFAULT_CHARSET = 'UTF-8';
|
||||||
|
|
||||||
/** @var string $contentType The content type */
|
/** @var string|null $contentType The content type */
|
||||||
protected $contentType;
|
protected $contentType = null;
|
||||||
|
|
||||||
/** @var string $charset The charset */
|
/** @var string $charset The charset */
|
||||||
protected $charset;
|
protected $charset;
|
||||||
@ -82,10 +82,18 @@ abstract class FormatAbstract implements FormatInterface {
|
|||||||
/**
|
/**
|
||||||
* Send header with the currently specified content type
|
* Send header with the currently specified content type
|
||||||
*
|
*
|
||||||
|
* @throws \LogicException if the content type is not set
|
||||||
|
* @throws \LogicException if the content type is not a string
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @todo This should throw an error if no content type is set
|
|
||||||
*/
|
*/
|
||||||
protected function callContentType(){
|
protected function callContentType(){
|
||||||
|
if(empty($this->contentType))
|
||||||
|
throw new \LogicException('Content-Type is not set!');
|
||||||
|
|
||||||
|
if(!is_string($this->contentType))
|
||||||
|
throw new \LogicException('Content-Type must be a string!');
|
||||||
|
|
||||||
header('Content-Type: ' . $this->contentType);
|
header('Content-Type: ' . $this->contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user