/**
  * @param Feed $feed
  */
 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;
             }
         }
     }
 }
Exemple #2
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
  */
 protected function getNextItem(Feed $feed)
 {
     try {
         return $feed->getNextItem();
     } catch (\Exception $exception) {
         $this->handleException($exception);
     }
     return null;
 }
Exemple #3
0
 public function testChangeContinueOnModificationException()
 {
     $feed = new Feed($this->reader);
     $feed->getEventDispatcher()->addListener(FeedEvents::ITEM_MODIFICATION_FAILED, function (FailedItemModificationEvent $e) {
         $e->setContinue(false);
     });
     $feed->addModifier(new CallbackTransformer(function () {
         throw new ModificationException();
     }), 1, true);
     $this->assertNull($feed->getNextItem(), 'The modification should have not continued');
 }