miniflux-legacy/vendor/fguillot/picofeed/lib/PicoFeed/Syndication/Writer.php

96 lines
1.6 KiB
PHP
Raw Normal View History

2013-06-29 03:50:15 +02:00
<?php
namespace PicoFeed\Syndication;
2013-06-29 03:50:15 +02:00
2014-05-20 20:20:27 +02:00
use RuntimeException;
/**
* Base writer class.
2014-05-20 20:20:27 +02:00
*
2014-10-19 20:42:31 +02:00
* @author Frederic Guillot
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.
2014-05-20 20:20:27 +02:00
*
2014-10-19 20:42:31 +02:00
* @var \DomDocument
2014-05-20 20:20:27 +02:00
*/
protected $dom;
/**
* Items.
2014-05-20 20:20:27 +02:00
*
* @var array
*/
2013-06-29 03:50:15 +02:00
public $items = array();
2014-10-19 20:42:31 +02:00
/**
* Author.
2014-10-19 20:42:31 +02:00
*
* @var array
*/
public $author = array();
/**
* Feed URL.
2014-10-19 20:42:31 +02:00
*
* @var string
*/
public $feed_url = '';
/**
* Website URL.
2014-10-19 20:42:31 +02:00
*
* @var string
*/
public $site_url = '';
/**
* Feed title.
2014-10-19 20:42:31 +02:00
*
* @var string
*/
public $title = '';
/**
* Feed description.
*
* @var string
*/
public $description = '';
2014-10-19 20:42:31 +02:00
/**
* Feed modification date (timestamp).
2014-10-19 20:42:31 +02:00
*
* @var int
2014-10-19 20:42:31 +02:00
*/
public $updated = 0;
2014-05-20 20:20:27 +02:00
/**
* Generate the XML document.
2014-05-20 20:20:27 +02:00
*
* @abstract
*
* @param string $filename Optional filename
*
2014-05-20 20:20:27 +02:00
* @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.
2014-05-20 20:20:27 +02:00
*
* @param array $properties List of properties
* @param mixed $container Object or array container
2014-05-20 20:20:27 +02:00
*/
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
}