miniflux-legacy/vendor/PicoFeed/Writer.php

98 lines
1.8 KiB
PHP
Raw Normal View History

2013-06-29 03:50:15 +02:00
<?php
namespace PicoFeed;
2014-05-20 20:20:27 +02:00
use RuntimeException;
/**
* Base writer class
*
2014-10-19 20:42:31 +02:00
* @author Frederic Guillot
* @package picofeed
* @property string $description Feed description
2014-05-20 20:20:27 +02:00
*/
2013-06-29 03:50:15 +02:00
abstract class Writer
{
2014-05-20 20:20:27 +02:00
/**
* Dom object
*
* @access protected
2014-10-19 20:42:31 +02:00
* @var \DomDocument
2014-05-20 20:20:27 +02:00
*/
protected $dom;
/**
* Items
*
* @access public
* @var array
*/
2013-06-29 03:50:15 +02:00
public $items = array();
2014-10-19 20:42:31 +02:00
/**
* 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;
2014-05-20 20:20:27 +02:00
/**
* Generate the XML document
*
* @abstract
* @access public
* @param string $filename Optional filename
* @return string
*/
2013-06-29 03:50:15 +02:00
abstract public function execute($filename = '');
2014-05-20 20:20:27 +02:00
/**
* 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)
2013-06-29 03:50:15 +02:00
{
foreach ($properties as $property) {
if ((is_object($container) && ! isset($container->$property)) || (is_array($container) && ! isset($container[$property]))) {
2014-05-20 20:20:27 +02:00
throw new RuntimeException('Required property missing: '.$property);
2013-06-29 03:50:15 +02:00
}
}
}
2014-05-20 20:20:27 +02:00
}