miniflux-legacy/vendor/PicoFeed/Writer.php

57 lines
1.2 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
*
* @author Frederic Guillot
* @package picofeed
*/
2013-06-29 03:50:15 +02:00
abstract class Writer
{
2014-05-20 20:20:27 +02:00
/**
* Dom object
*
* @access protected
* @var DomDocument
*/
protected $dom;
/**
* Items
*
* @access public
* @var array
*/
2013-06-29 03:50:15 +02:00
public $items = array();
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
}