diff options
Diffstat (limited to 'vendor/fguillot/picofeed/lib/PicoFeed/Parser')
12 files changed, 485 insertions, 681 deletions
diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php index 6950d9afd..356453c9d 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php @@ -7,25 +7,24 @@ use PicoFeed\Filter\Filter; use PicoFeed\Client\Url; /** - * Atom parser + * Atom parser. * * @author Frederic Guillot - * @package Parser */ class Atom extends Parser { /** - * Supported namespaces + * Supported namespaces. */ protected $namespaces = array( 'atom' => 'http://www.w3.org/2005/Atom', ); /** - * Get the path to the items XML tree + * Get the path to the items XML tree. + * + * @param SimpleXMLElement $xml Feed xml * - * @access public - * @param SimpleXMLElement $xml Feed xml * @return SimpleXMLElement */ public function getItemsTree(SimpleXMLElement $xml) @@ -35,11 +34,10 @@ class Atom extends Parser } /** - * Find the feed url + * Find the feed url. * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $xml Feed xml + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findFeedUrl(SimpleXMLElement $xml, Feed $feed) { @@ -47,11 +45,10 @@ class Atom extends Parser } /** - * Find the site url + * Find the site url. * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $xml Feed xml + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findSiteUrl(SimpleXMLElement $xml, Feed $feed) { @@ -59,11 +56,10 @@ class Atom extends Parser } /** - * Find the feed description + * Find the feed description. * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $xml Feed xml + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findFeedDescription(SimpleXMLElement $xml, Feed $feed) { @@ -74,11 +70,10 @@ class Atom extends Parser } /** - * Find the feed logo url + * Find the feed logo url. * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $xml Feed xml + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findFeedLogo(SimpleXMLElement $xml, Feed $feed) { @@ -89,11 +84,10 @@ class Atom extends Parser } /** - * Find the feed icon + * Find the feed icon. * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $xml Feed xml + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findFeedIcon(SimpleXMLElement $xml, Feed $feed) { @@ -104,11 +98,10 @@ class Atom extends Parser } /** - * Find the feed title + * Find the feed title. * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $xml Feed xml + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findFeedTitle(SimpleXMLElement $xml, Feed $feed) { @@ -119,11 +112,10 @@ class Atom extends Parser } /** - * Find the feed language + * Find the feed language. * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $xml Feed xml + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findFeedLanguage(SimpleXMLElement $xml, Feed $feed) { @@ -134,11 +126,10 @@ class Atom extends Parser } /** - * Find the feed id + * Find the feed id. * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $xml Feed xml + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findFeedId(SimpleXMLElement $xml, Feed $feed) { @@ -149,11 +140,10 @@ class Atom extends Parser } /** - * Find the feed date + * Find the feed date. * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $xml Feed xml + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findFeedDate(SimpleXMLElement $xml, Feed $feed) { @@ -164,12 +154,11 @@ class Atom extends Parser } /** - * Find the item date + * Find the item date. * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $entry Feed item + * @param Item $item Item object + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed) { @@ -179,26 +168,23 @@ class Atom extends Parser $updated = XmlParser::getXPathResult($entry, 'atom:updated', $this->namespaces) ?: XmlParser::getXPathResult($entry, 'updated'); - $published = ! empty($published) ? $this->date->getDateTime((string) current($published)) : null; - $updated = ! empty($updated) ? $this->date->getDateTime((string) current($updated)) : null; + $published = !empty($published) ? $this->date->getDateTime((string) current($published)) : null; + $updated = !empty($updated) ? $this->date->getDateTime((string) current($updated)) : null; if ($published === null && $updated === null) { $item->date = $feed->getDate(); // We use the feed date if there is no date for the item - } - else if ($published !== null && $updated !== null) { + } elseif ($published !== null && $updated !== null) { $item->date = max($published, $updated); // We use the most recent date between published and updated - } - else { + } else { $item->date = $updated ?: $published; } } /** - * Find the item title + * Find the item title. * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param Item $item Item object + * @param SimpleXMLElement $entry Feed item + * @param Item $item Item object */ public function findItemTitle(SimpleXMLElement $entry, Item $item) { @@ -209,12 +195,11 @@ class Atom extends Parser } /** - * Find the item author + * Find the item author. * - * @access public - * @param SimpleXMLElement $xml Feed - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object + * @param SimpleXMLElement $xml Feed + * @param SimpleXMLElement $entry Feed item + * @param \PicoFeed\Parser\Item $item Item object */ public function findItemAuthor(SimpleXMLElement $xml, SimpleXMLElement $entry, Item $item) { @@ -227,11 +212,10 @@ class Atom extends Parser } /** - * Find the item content + * Find the item content. * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object + * @param SimpleXMLElement $entry Feed item + * @param \PicoFeed\Parser\Item $item Item object */ public function findItemContent(SimpleXMLElement $entry, Item $item) { @@ -239,11 +223,10 @@ class Atom extends Parser } /** - * Find the item URL + * Find the item URL. * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object + * @param SimpleXMLElement $entry Feed item + * @param \PicoFeed\Parser\Item $item Item object */ public function findItemUrl(SimpleXMLElement $entry, Item $item) { @@ -251,22 +234,20 @@ class Atom extends Parser } /** - * Genereate the item id + * Genereate the item id. * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $entry Feed item + * @param \PicoFeed\Parser\Item $item Item object + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findItemId(SimpleXMLElement $entry, Item $item, Feed $feed) { $id = XmlParser::getXPathResult($entry, 'atom:id', $this->namespaces) ?: XmlParser::getXPathResult($entry, 'id'); - if (! empty($id)) { + if (!empty($id)) { $item->id = $this->generateId((string) current($id)); - } - else { + } else { $item->id = $this->generateId( $item->getTitle(), $item->getUrl(), $item->getContent() ); @@ -274,12 +255,11 @@ class Atom extends Parser } /** - * Find the item enclosure + * Find the item enclosure. * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $entry Feed item + * @param \PicoFeed\Parser\Item $item Item object + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed) { @@ -292,12 +272,11 @@ class Atom extends Parser } /** - * Find the item language + * Find the item language. * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object + * @param SimpleXMLElement $entry Feed item + * @param \PicoFeed\Parser\Item $item Item object + * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed) { @@ -307,11 +286,11 @@ class Atom extends Parser } /** - * Get the URL from a link tag + * Get the URL from a link tag. + * + * @param SimpleXMLElement $xml XML tag + * @param string $rel Link relationship: alternate, enclosure, related, self, via * - * @access private - * @param SimpleXMLElement $xml XML tag - * @param string $rel Link relationship: alternate, enclosure, related, self, via * @return string */ private function getUrl(SimpleXMLElement $xml, $rel, $fallback = false) @@ -324,6 +303,7 @@ class Atom extends Parser if ($fallback) { $link = $this->findLink($xml, ''); + return $link ? (string) $link['href'] : ''; } @@ -331,11 +311,11 @@ class Atom extends Parser } /** - * Get a link tag that match a relationship + * Get a link tag that match a relationship. + * + * @param SimpleXMLElement $xml XML tag + * @param string $rel Link relationship: alternate, enclosure, related, self, via * - * @access private - * @param SimpleXMLElement $xml XML tag - * @param string $rel Link relationship: alternate, enclosure, related, self, via * @return SimpleXMLElement|null */ private function findLink(SimpleXMLElement $xml, $rel) @@ -349,14 +329,14 @@ class Atom extends Parser } } - return null; + return; } /** - * Get the entry content + * Get the entry content. + * + * @param SimpleXMLElement $entry XML Entry * - * @access private - * @param SimpleXMLElement $entry XML Entry * @return string */ private function getContent(SimpleXMLElement $entry) @@ -366,16 +346,15 @@ class Atom extends Parser ?: XmlParser::getXPathResult($entry, 'content') ); - if (! empty($content) && count($content->children())) { + if (!empty($content) && count($content->children())) { $xml_string = ''; - foreach($content->children() as $child) { + foreach ($content->children() as $child) { $xml_string .= $child->asXML(); } return $xml_string; - } - else if (trim((string) $content) !== '') { + } elseif (trim((string) $content) !== '') { return (string) $content; } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php index 4612a8613..e4d08b527 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php @@ -6,25 +6,22 @@ use DateTime; use DateTimeZone; /** - * Date Parser + * Date Parser. * * @author Frederic Guillot - * @package Parser */ class DateParser { /** - * Timezone used to parse feed dates + * Timezone used to parse feed dates. * - * @access public * @var string */ public $timezone = 'UTC'; /** - * Supported formats [ 'format' => length ] + * Supported formats [ 'format' => length ]. * - * @access public * @var array */ public $formats = array( @@ -56,10 +53,10 @@ class DateParser ); /** - * Try to parse all date format for broken feeds + * Try to parse all date format for broken feeds. + * + * @param string $value Original date format * - * @access public - * @param string $value Original date format * @return DateTime */ public function getDateTime($value) @@ -67,7 +64,6 @@ class DateParser $value = trim($value); foreach ($this->formats as $format => $length) { - $truncated_value = $value; if ($length !== null) { $truncated_value = substr($truncated_value, 0, $length); @@ -83,19 +79,18 @@ class DateParser } /** - * Get a valid date from a given format + * Get a valid date from a given format. * - * @access public - * @param string $format Date format - * @param string $value Original date value - * @return DateTime|boolean + * @param string $format Date format + * @param string $value Original date value + * + * @return DateTime|bool */ public function getValidDate($format, $value) { $date = DateTime::createFromFormat($format, $value, new DateTimeZone($this->timezone)); if ($date !== false) { - $errors = DateTime::getLastErrors(); if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) { @@ -107,9 +102,8 @@ class DateParser } /** - * Get the current datetime + * Get the current datetime. * - * @access public * @return DateTime */ public function getCurrentDateTime() diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php index 93831e746..bf2bacfb0 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php @@ -3,98 +3,84 @@ namespace PicoFeed\Parser; /** - * Feed + * Feed. * * @author Frederic Guillot - * @package Parser */ class Feed { /** - * Feed items + * Feed items. * - * @access public * @var array */ public $items = array(); /** - * Feed id + * Feed id. * - * @access public * @var string */ public $id = ''; /** - * Feed title + * Feed title. * - * @access public * @var string */ public $title = ''; /** - * Feed description + * Feed description. * - * @access public * @var string */ public $description = ''; /** - * Feed url + * Feed url. * - * @access public * @var string */ public $feed_url = ''; /** - * Site url + * Site url. * - * @access public * @var string */ public $site_url = ''; /** - * Feed date + * Feed date. * - * @access public * @var \DateTime */ public $date = null; /** - * Feed language + * Feed language. * - * @access public * @var string */ public $language = ''; /** - * Feed logo URL + * Feed logo URL. * - * @access public * @var string */ public $logo = ''; /** - * Feed icon URL + * Feed icon URL. * - * @access public * @var string */ public $icon = ''; /** - * Return feed information - * - * @access public - * $return string + * Return feed information. */ public function __toString() { @@ -117,10 +103,7 @@ class Feed } /** - * Get title - * - * @access public - * $return string + * Get title. */ public function getTitle() { @@ -128,10 +111,7 @@ class Feed } /** - * Get description - * - * @access public - * $return string + * Get description. */ public function getDescription() { @@ -139,10 +119,7 @@ class Feed } /** - * Get the logo url - * - * @access public - * $return string + * Get the logo url. */ public function getLogo() { @@ -150,10 +127,7 @@ class Feed } /** - * Get the icon url - * - * @access public - * $return string + * Get the icon url. */ public function getIcon() { @@ -161,10 +135,7 @@ class Feed } /** - * Get feed url - * - * @access public - * $return string + * Get feed url. */ public function getFeedUrl() { @@ -172,10 +143,7 @@ class Feed } /** - * Get site url - * - * @access public - * $return string + * Get site url. */ public function getSiteUrl() { @@ -183,10 +151,7 @@ class Feed } /** - * Get date - * - * @access public - * $return integer + * Get date. */ public function getDate() { @@ -194,10 +159,7 @@ class Feed } /** - * Get language - * - * @access public - * $return string + * Get language. */ public function getLanguage() { @@ -205,10 +167,7 @@ class Feed } /** - * Get id - * - * @access public - * $return string + * Get id. */ public function getId() { @@ -216,10 +175,7 @@ class Feed } /** - * Get feed items - * - * @access public - * $return array + * Get feed items. */ public function getItems() { @@ -227,9 +183,8 @@ class Feed } /** - * Return true if the feed is "Right to Left" + * Return true if the feed is "Right to Left". * - * @access public * @return bool */ public function isRTL() diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php index c9dff5a6f..22d7c5951 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php @@ -3,17 +3,15 @@ namespace PicoFeed\Parser; /** - * Feed Item + * Feed Item. * * @author Frederic Guillot - * @package Parser */ class Item { /** - * List of known RTL languages + * List of known RTL languages. * - * @access public * @var public */ public $rtl = array( @@ -28,100 +26,89 @@ class Item ); /** - * Item id + * Item id. * - * @access public * @var string */ public $id = ''; /** - * Item title + * Item title. * - * @access public * @var string */ public $title = ''; /** - * Item url + * Item url. * - * @access public * @var string */ public $url = ''; /** - * Item author + * Item author. * - * @access public * @var string */ - public $author= ''; + public $author = ''; /** - * Item date + * Item date. * - * @access public * @var \DateTime */ public $date = null; /** - * Item content + * Item content. * - * @access public * @var string */ public $content = ''; /** - * Item enclosure url + * Item enclosure url. * - * @access public * @var string */ public $enclosure_url = ''; /** - * Item enclusure type + * Item enclusure type. * - * @access public * @var string */ public $enclosure_type = ''; /** - * Item language + * Item language. * - * @access public * @var string */ public $language = ''; /** - * Raw XML + * Raw XML. * - * @access public * @var \SimpleXMLElement */ public $xml; /** - * List of namespaces + * List of namespaces. * - * @access public * @var array */ public $namespaces = array(); /** - * Get specific XML tag or attribute value + * Get specific XML tag or attribute value. * - * @access public - * @param string $tag Tag name (examples: guid, media:content) - * @param string $attribute Tag attribute - * @return array|false Tag values or error + * @param string $tag Tag name (examples: guid, media:content) + * @param string $attribute Tag attribute + * + * @return array|false Tag values or error */ public function getTag($tag, $attribute = '') { @@ -142,10 +129,7 @@ class Item } /** - * Return item information - * - * @access public - * $return string + * Return item information. */ public function __toString() { @@ -163,10 +147,7 @@ class Item } /** - * Get title - * - * @access public - * $return string + * Get title. */ public function getTitle() { @@ -174,10 +155,7 @@ class Item } /** - * Get url - * - * @access public - * $return string + * Get url. */ public function getUrl() { @@ -185,10 +163,7 @@ class Item } /** - * Get id - * - * @access public - * $return string + * Get id. */ public function getId() { @@ -196,10 +171,7 @@ class Item } /** - * Get date - * - * @access public - * $return \DateTime + * Get date. */ public function getDate() { @@ -207,10 +179,7 @@ class Item } /** - * Get content - * - * @access public - * $return string + * Get content. */ public function getContent() { @@ -218,10 +187,7 @@ class Item } /** - * Get enclosure url - * - * @access public - * $return string + * Get enclosure url. */ public function getEnclosureUrl() { @@ -229,10 +195,7 @@ class Item } /** - * Get enclosure type - * - * @access public - * $return string + * Get enclosure type. */ public function getEnclosureType() { @@ -240,10 +203,7 @@ class Item } /** - * Get language - * - * @access public - * $return string + * Get language. */ public function getLanguage() { @@ -251,10 +211,7 @@ class Item } /** - * Get author - * - * @access public - * $return string + * Get author. */ public function getAuthor() { @@ -262,9 +219,8 @@ class Item } /** - * Return true if the item is "Right to Left" + * Return true if the item is "Right to Left". * - * @access public * @return bool */ public function isRTL() diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php index 8464e9cac..05b0387dc 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php @@ -3,11 +3,10 @@ namespace PicoFeed\Parser; /** - * MalformedXmlException Exception + * MalformedXmlException Exception. * * @author Frederic Guillot - * @package Parser */ class MalformedXmlException extends ParserException { -}
\ No newline at end of file +} |