Skip to content

Commit

Permalink
Simplifying revert's code. (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmizzell authored Jan 11, 2020
1 parent fc16170 commit 44368ed
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Harvester.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ public function revert()
{
$ids = $this->factory->hashStorage->retrieveAll();
$load = $this->factory->get("load");

if (!method_exists($load, "removeItem")) {
throw new \Exception("Load of class " . get_class($load) . " does not implement the removeItem method.");
}

$counter = 0;
foreach ($ids as $id) {
if (method_exists($load, "removeItem")) {
$load->removeItem($id);
$this->factory->hashStorage->remove($id);
$counter++;
}
$load->removeItem($id);
$this->factory->hashStorage->remove($id);
$counter++;
}

return $counter;
}

Expand Down

0 comments on commit 44368ed

Please sign in to comment.