annotate vendor/zendframework/zend-feed/src/Reader/Extension/Slash/Entry.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 7a779792577d
children
rev   line source
Chris@0 1 <?php
Chris@0 2 /**
Chris@0 3 * Zend Framework (http://framework.zend.com/)
Chris@0 4 *
Chris@0 5 * @link http://github.com/zendframework/zf2 for the canonical source repository
Chris@0 6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
Chris@0 7 * @license http://framework.zend.com/license/new-bsd New BSD License
Chris@0 8 */
Chris@0 9
Chris@0 10 namespace Zend\Feed\Reader\Extension\Slash;
Chris@0 11
Chris@0 12 use Zend\Feed\Reader\Extension;
Chris@0 13
Chris@0 14 /**
Chris@0 15 */
Chris@0 16 class Entry extends Extension\AbstractEntry
Chris@0 17 {
Chris@0 18 /**
Chris@0 19 * Get the entry section
Chris@0 20 *
Chris@0 21 * @return string|null
Chris@0 22 */
Chris@0 23 public function getSection()
Chris@0 24 {
Chris@0 25 return $this->getData('section');
Chris@0 26 }
Chris@0 27
Chris@0 28 /**
Chris@0 29 * Get the entry department
Chris@0 30 *
Chris@0 31 * @return string|null
Chris@0 32 */
Chris@0 33 public function getDepartment()
Chris@0 34 {
Chris@0 35 return $this->getData('department');
Chris@0 36 }
Chris@0 37
Chris@0 38 /**
Chris@0 39 * Get the entry hit_parade
Chris@0 40 *
Chris@0 41 * @return array
Chris@0 42 */
Chris@0 43 public function getHitParade()
Chris@0 44 {
Chris@0 45 $name = 'hit_parade';
Chris@0 46
Chris@0 47 if (isset($this->data[$name])) {
Chris@0 48 return $this->data[$name];
Chris@0 49 }
Chris@0 50
Chris@0 51 $stringParade = $this->getData($name);
Chris@0 52 $hitParade = [];
Chris@0 53
Chris@12 54 if (! empty($stringParade)) {
Chris@0 55 $stringParade = explode(',', $stringParade);
Chris@0 56
Chris@0 57 foreach ($stringParade as $hit) {
Chris@0 58 $hitParade[] = $hit + 0; //cast to integer
Chris@0 59 }
Chris@0 60 }
Chris@0 61
Chris@0 62 $this->data[$name] = $hitParade;
Chris@0 63 return $hitParade;
Chris@0 64 }
Chris@0 65
Chris@0 66 /**
Chris@0 67 * Get the entry comments
Chris@0 68 *
Chris@0 69 * @return int
Chris@0 70 */
Chris@0 71 public function getCommentCount()
Chris@0 72 {
Chris@0 73 $name = 'comments';
Chris@0 74
Chris@0 75 if (isset($this->data[$name])) {
Chris@0 76 return $this->data[$name];
Chris@0 77 }
Chris@0 78
Chris@0 79 $comments = $this->getData($name, 'string');
Chris@0 80
Chris@12 81 if (! $comments) {
Chris@0 82 $this->data[$name] = null;
Chris@0 83 return $this->data[$name];
Chris@0 84 }
Chris@0 85
Chris@0 86 return $comments;
Chris@0 87 }
Chris@0 88
Chris@0 89 /**
Chris@0 90 * Get the entry data specified by name
Chris@0 91 * @param string $name
Chris@0 92 * @param string $type
Chris@0 93 *
Chris@0 94 * @return mixed|null
Chris@0 95 */
Chris@0 96 protected function getData($name, $type = 'string')
Chris@0 97 {
Chris@0 98 if (array_key_exists($name, $this->data)) {
Chris@0 99 return $this->data[$name];
Chris@0 100 }
Chris@0 101
Chris@0 102 $data = $this->xpath->evaluate($type . '(' . $this->getXpathPrefix() . '/slash10:' . $name . ')');
Chris@0 103
Chris@12 104 if (! $data) {
Chris@0 105 $data = null;
Chris@0 106 }
Chris@0 107
Chris@0 108 $this->data[$name] = $data;
Chris@0 109
Chris@0 110 return $data;
Chris@0 111 }
Chris@0 112
Chris@0 113 /**
Chris@0 114 * Register Slash namespaces
Chris@0 115 *
Chris@0 116 * @return void
Chris@0 117 */
Chris@0 118 protected function registerNamespaces()
Chris@0 119 {
Chris@0 120 $this->xpath->registerNamespace('slash10', 'http://purl.org/rss/1.0/modules/slash/');
Chris@0 121 }
Chris@0 122 }