. * */ namespace OCA\News\ArticleEnhancer; use \OCA\News\Utility\SimplePieFileFactory; use \OCA\News\Db\Item; class RegexArticleEnhancer implements ArticleEnhancer { private $matchArticleUrl; private $regexPair; public function __construct($matchArticleUrl, array $regexPair) { $this->matchArticleUrl = $matchArticleUrl; $this->regexPair = $regexPair; } public function enhance(Item $item) { if (preg_match($this->matchArticleUrl, $item->getUrl())) { $body = $item->getBody(); foreach($this->regexPair as $search => $replaceWith) { $body = preg_replace($search, $replaceWith, $body); } $item->setBody($body); } return $item; } }