miniflux-legacy/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php

195 lines
2.9 KiB
PHP
Raw Normal View History

2014-05-20 20:20:27 +02:00
<?php
namespace PicoFeed\Parser;
2014-05-20 20:20:27 +02:00
/**
* Feed.
2014-05-20 20:20:27 +02:00
*
* @author Frederic Guillot
*/
class Feed
{
/**
* Feed items.
2014-05-20 20:20:27 +02:00
*
* @var array
*/
public $items = array();
/**
* Feed id.
2014-05-20 20:20:27 +02:00
*
* @var string
*/
public $id = '';
/**
* Feed title.
2014-05-20 20:20:27 +02:00
*
* @var string
*/
public $title = '';
/**
* Feed description.
2014-10-19 20:42:31 +02:00
*
* @var string
*/
public $description = '';
/**
* Feed url.
2014-05-20 20:20:27 +02:00
*
* @var string
*/
public $feed_url = '';
/**
* Site url.
*
* @var string
*/
public $site_url = '';
2014-05-20 20:20:27 +02:00
/**
* Feed date.
2014-05-20 20:20:27 +02:00
*
2015-03-01 19:56:11 +01:00
* @var \DateTime
2014-05-20 20:20:27 +02:00
*/
2015-03-01 19:56:11 +01:00
public $date = null;
2014-05-20 20:20:27 +02:00
/**
* Feed language.
2014-05-20 20:20:27 +02:00
*
* @var string
*/
public $language = '';
2014-10-19 20:42:31 +02:00
/**
* Feed logo URL.
2014-10-19 20:42:31 +02:00
*
* @var string
*/
public $logo = '';
/**
* Feed icon URL.
*
* @var string
*/
public $icon = '';
2014-05-20 20:20:27 +02:00
/**
* Return feed information.
2014-05-20 20:20:27 +02:00
*/
public function __toString()
{
$output = '';
2015-03-01 19:56:11 +01:00
foreach (array('id', 'title', 'feed_url', 'site_url', 'language', 'description', 'logo') as $property) {
2014-05-20 20:20:27 +02:00
$output .= 'Feed::'.$property.' = '.$this->$property.PHP_EOL;
}
2015-03-01 19:56:11 +01:00
$output .= 'Feed::date = '.$this->date->format(DATE_RFC822).PHP_EOL;
$output .= 'Feed::isRTL() = '.($this->isRTL() ? 'true' : 'false').PHP_EOL;
2014-05-20 20:20:27 +02:00
$output .= 'Feed::items = '.count($this->items).' items'.PHP_EOL;
foreach ($this->items as $item) {
$output .= '----'.PHP_EOL;
$output .= $item;
}
return $output;
}
/**
* Get title.
2014-05-20 20:20:27 +02:00
*/
public function getTitle()
{
return $this->title;
}
2014-10-19 20:42:31 +02:00
/**
* Get description.
2014-10-19 20:42:31 +02:00
*/
public function getDescription()
{
return $this->description;
}
/**
* Get the logo url.
2014-10-19 20:42:31 +02:00
*/
public function getLogo()
{
return $this->logo;
}
/**
* Get the icon url.
*/
public function getIcon()
{
return $this->icon;
}
2014-05-20 20:20:27 +02:00
/**
* Get feed url.
2014-05-20 20:20:27 +02:00
*/
public function getFeedUrl()
2014-05-20 20:20:27 +02:00
{
return $this->feed_url;
}
/**
* Get site url.
*/
public function getSiteUrl()
{
return $this->site_url;
2014-05-20 20:20:27 +02:00
}
/**
* Get date.
2014-05-20 20:20:27 +02:00
*/
public function getDate()
{
return $this->date;
}
/**
* Get language.
2014-05-20 20:20:27 +02:00
*/
public function getLanguage()
{
return $this->language;
}
/**
* Get id.
2014-05-20 20:20:27 +02:00
*/
public function getId()
{
return $this->id;
}
/**
* Get feed items.
2014-05-20 20:20:27 +02:00
*/
public function getItems()
{
return $this->items;
}
/**
* Return true if the feed is "Right to Left".
*
* @return bool
*/
public function isRTL()
{
return Parser::isLanguageRTL($this->language);
}
2014-05-20 20:20:27 +02:00
}