3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Feed\Reader\Extension\Syndication
;
14 use Zend\Feed\Reader\Extension
;
16 class Feed
extends Extension\AbstractFeed
22 * @throws Reader\Exception\InvalidArgumentException
24 public function getUpdatePeriod()
26 $name = 'updatePeriod';
27 $period = $this->_getData($name);
29 if ($period === null) {
30 $this->data
[$name] = 'daily';
31 return 'daily'; //Default specified by spec
41 throw new Reader\Exception\
InvalidArgumentException("Feed specified invalid update period: '$period'."
42 . " Must be one of hourly, daily, weekly or yearly"
48 * Get update frequency
52 public function getUpdateFrequency()
54 $name = 'updateFrequency';
55 $freq = $this->_getData($name, 'number');
57 if (!$freq ||
$freq < 1) {
58 $this->data
[$name] = 1;
66 * Get update frequency as ticks
70 public function getUpdateFrequencyAsTicks()
72 $name = 'updateFrequency';
73 $freq = $this->_getData($name, 'number');
75 if (!$freq ||
$freq < 1) {
76 $this->data
[$name] = 1;
80 $period = $this->getUpdatePeriod();
85 $ticks *= 52; //TODO: fix generalisation, how?
96 default: //Never arrive here, exception thrown in getPeriod()
100 return $ticks / $freq;
106 * @return DateTime|null
108 public function getUpdateBase()
110 $updateBase = $this->_getData('updateBase');
113 $date = DateTime
::createFromFormat(DateTime
::W3C
, $updateBase);
119 * Get the entry data specified by name
121 * @param string $name
122 * @param string $type
125 private function _getData($name, $type = 'string')
127 if (array_key_exists($name, $this->data
)) {
128 return $this->data
[$name];
131 $data = $this->xpath
->evaluate($type . '(' . $this->getXpathPrefix() . '/syn10:' . $name . ')');
137 $this->data
[$name] = $data;
143 * Register Syndication namespaces
147 protected function registerNamespaces()
149 $this->xpath
->registerNamespace('syn10', 'http://purl.org/rss/1.0/modules/syndication/');