Skip to content

Commit

Permalink
Merge pull request #71 from alexdebril/issue/70
Browse files Browse the repository at this point in the history
Issue/70
  • Loading branch information
alexdebril authored Jan 9, 2017
2 parents 0ced003 + 39b47cb commit ea753c4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/FeedIo/FeedIo.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,16 @@ public function readSince($url, \DateTime $modifiedSince)
return $this->read($url, new Feed(), $modifiedSince);
}

/**
* @return $this
*/
public function resetFilters()
{
$this->getReader()->resetFilters();

return $this;
}

/**
* @param FeedInterface $feed
* @param string $standard Standard's name
Expand Down
11 changes: 11 additions & 0 deletions src/FeedIo/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ public function addFilter(FilterInterface $filter)
return $this;
}

/**
* Reset filters
* @return $this
*/
public function resetFilters()
{
$this->filters = [];

return $this;
}

/**
* @param DOMDocument $document
* @param FeedInterface $feed
Expand Down
13 changes: 13 additions & 0 deletions src/FeedIo/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ public function addFilter(FilterInterface $filter)
return $this;
}

/**
* Reset filters on every parsers
* @return $this
*/
public function resetFilters()
{
foreach ($this->parsers as $parser) {
$parser->resetFilters();
}

return $this;
}

/**
* @param string $body
* @return \DOMDocument
Expand Down
10 changes: 10 additions & 0 deletions tests/FeedIo/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ public function testCheckBadStructure()
);
}

public function testAddResetFilters()
{
$filter = $this->getMockForAbstractClass('\FeedIo\FilterInterface');

$this->object->addFilter($filter);
$this->assertAttributeCount(1, 'filters', $this->object);
$this->object->resetFilters();
$this->assertAttributeCount(0, 'filters', $this->object);
}

/**
* @param boolean $returnValue
* @return \FeedIo\FilterInterface
Expand Down

0 comments on commit ea753c4

Please sign in to comment.