protected function inspect(Feed $feed)
 {
     while ($item = $feed->getNextItem()) {
         foreach ($item->all() as $key => $value) {
             if (!array_key_exists($key, $this->data)) {
                 $this->data[$key] = [];
             }
             $hash = md5(serialize($value));
             if (!array_key_exists($hash, $this->data[$key])) {
                 $this->data[$key][$hash] = 0;
             }
             $this->data[$key][$hash]++;
             if (!array_key_exists($hash, $this->values)) {
                 $this->values[$hash] = $value;
             }
         }
     }
 }
示例#2
0
 /**
  * @param ReaderInterface          $reader
  * @param EventDispatcherInterface $dispatcher
  * @param string                   $itemName
  *
  * @return Feed
  */
 protected function createFeed(ReaderInterface $reader, EventDispatcherInterface $dispatcher, $itemName)
 {
     if ($reader instanceof XmlReader) {
         $reader->setNodeCallback($itemName);
     }
     $feed = new Feed($reader, $dispatcher);
     /** @var ModifierInterface $modifier */
     foreach ($this->modifiers as $position => list($modifier, $continue)) {
         $feed->addModifier($modifier, $position, $continue);
     }
     return $feed;
 }
示例#3
0
 /**
  * Returns the next item in the feed, or null if no more items are left.
  * Use this when iterating over the feed.
  *
  * @param  Feed             $feed
  * @return FeedItemBag|null
  */
 public function getNextItem(Feed $feed)
 {
     try {
         return $feed->getNextItem();
     } catch (\Exception $exception) {
         $this->handleException($exception);
     }
     return null;
 }