diff --git a/src/AdsPostParser.php b/src/AdsPostParser.php index be86179..077100f 100755 --- a/src/AdsPostParser.php +++ b/src/AdsPostParser.php @@ -4,7 +4,6 @@ use Illuminate\Support\Facades\Blade; use voku\helper\HtmlDomParser; -use function DI\string; class AdsPostParser { @@ -42,14 +41,15 @@ public function appendAdvertising(): string $currentElement = $item; $afterElement = $index < count($items) - 1 ? $items[$index + 1] : null; - $isBlackList = preg_match('/' . implode('|', $blacklist) . '/', $currentElement->outertext) || ($afterElement ? preg_match('/' . implode('|', $blacklist) . '/', $afterElement->outertext) : false); + $isBlackList = preg_match('/'.implode('|', $blacklist).'/', $currentElement->outertext) || ($afterElement ? preg_match('/'.implode('|', $blacklist).'/', $afterElement->outertext) : false); // === END BLACKLIST === if (in_array($index, $thresholds)) { if ($isBlackList) { - $thresholds = array_map(function($value) { + $thresholds = array_map(function ($value) { return $value + 1; }, $thresholds); + continue; } @@ -79,7 +79,6 @@ public function oldappendAdvertising(): string return $this->dom->save(); } - /** * Append a single advertising */ @@ -95,7 +94,6 @@ public function appendSingleAdvertising(int $index, int $advIndex): string $beforeItem = $items[$index]; $nextItem = $index < $maxLoop - 1 ? $items[$index + 1] : null; - if ( ! preg_match($this->blacklistBefore, $beforeItem->outertext) && ($nextItem === null || ! preg_match($this->blacklistAfter, $nextItem->outertext)) ) { @@ -111,5 +109,4 @@ public function appendSingleAdvertising(int $index, int $advIndex): string return $this->dom->save(); } - }