miniflux-legacy/vendor/PicoFeed/Writer.php
2014-10-19 14:42:31 -04:00

98 lines
1.8 KiB
PHP

<?php
namespace PicoFeed;
use RuntimeException;
/**
* Base writer class
*
* @author Frederic Guillot
* @package picofeed
* @property string $description Feed description
*/
abstract class Writer
{
/**
* Dom object
*
* @access protected
* @var \DomDocument
*/
protected $dom;
/**
* Items
*
* @access public
* @var array
*/
public $items = array();
/**
* Author
*
* @access public
* @var array
*/
public $author = array();
/**
* Feed URL
*
* @access public
* @var string
*/
public $feed_url = '';
/**
* Website URL
*
* @access public
* @var string
*/
public $site_url = '';
/**
* Feed title
*
* @access public
* @var string
*/
public $title = '';
/**
* Feed modification date (timestamp)
*
* @access public
* @var integer
*/
public $updated = 0;
/**
* Generate the XML document
*
* @abstract
* @access public
* @param string $filename Optional filename
* @return string
*/
abstract public function execute($filename = '');
/**
* Check required properties to generate the output
*
* @access public
* @param array $properties List of properties
* @param mixed $container Object or array container
*/
public function checkRequiredProperties(array $properties, $container)
{
foreach ($properties as $property) {
if ((is_object($container) && ! isset($container->$property)) || (is_array($container) && ! isset($container[$property]))) {
throw new RuntimeException('Required property missing: '.$property);
}
}
}
}