private getSiblingContent ( DOMWrap\Element $currentSibling, integer $baselineScoreForSiblingParagraphs ) : DOMWrap\Element[] | ||
$currentSibling | DOMWrap\Element | |
$baselineScoreForSiblingParagraphs | integer | |
return | DOMWrap\Element[] |
private function getSiblingContent(Element $currentSibling, $baselineScoreForSiblingParagraphs)
{
$text = trim($currentSibling->text());
if ($currentSibling->is('p, strong') && !empty($text)) {
return [$currentSibling];
}
$results = [];
$nodes = $currentSibling->find('p, strong');
foreach ($nodes as $node) {
$text = trim($node->text());
if (!empty($text)) {
$wordStats = $this->config()->getStopWords()->getStopwordCount($text);
if ($baselineScoreForSiblingParagraphs * self::$SIBLING_BASE_LINE_SCORE < $wordStats->getStopWordCount()) {
$results[] = $node->document()->createElement('p', $text);
}
}
}
return $results;
}