private function isOkToBoost(Element $node): bool {
        $stepsAway = 0;
        $minimumStopWordCount = 5;
        $maxStepsAwayFromNode = 3;

        // Find all previous sibling element nodes
        $siblings = $node->precedingAll(function($node) {
            return $node instanceof Element;
        });

        foreach ($siblings as $sibling) {
            if ($sibling->is('p, strong')) {
                if ($stepsAway >= $maxStepsAwayFromNode) {
                    return false;
                }

                $wordStats = $this->config()->getStopWords()->getStopwordCount($sibling->text());

                if ($wordStats->getStopWordCount() > $minimumStopWordCount) {
                    return true;
                }

                $stepsAway += 1;
            }
        }

        return false;
    }
private function isOkToBoost(Element $node): bool {
        $stepsAway = 0;
        $minimumStopWordCount = 5;
        $maxStepsAwayFromNode = 3;

        // Find all previous sibling element nodes
        $siblings = $node->precedingAll(function($node) {
            return $node instanceof Element;
        });

        foreach ($siblings as $sibling) {
            if ($sibling->is('p, strong')) {
                if ($stepsAway >= $maxStepsAwayFromNode) {
                    return false;
                }

                $wordStats = $this->config()->getStopWords()->getStopwordCount($sibling->text());

                if ($wordStats->getStopWordCount() > $minimumStopWordCount) {
                    return true;
                }

                $stepsAway += 1;
            }
        }

        return false;
    }
private function isOkToBoost ( Element $ node ) : bool { $ stepsAway = 0 ; $ minimumStopWordCount = 5 ; $ maxStepsAwayFromNode = 3 ; // Find all previous sibling element nodes $ siblings = $ node -> precedingAll ( function ( $ node ) { return $ node instanceof Element ; } ) ; foreach ( $ siblings as $ sibling ) { if ( $ sibling -> is ( 'p, strong' ) ) { if ( $ stepsAway >= $ maxStepsAwayFromNode ) { return false ; } $ wordStats = $ this -> config ( ) -> getStopWords ( ) -> getStopwordCount ( $ sibling -> text ( ) ) ; if ( $ wordStats -> getStopWordCount ( ) > $ minimumStopWordCount ) { return true ; } $ stepsAway += 1 ; } } return false ; }
A lot of times the first paragraph might be the caption under an image so we'll want to make sure if we're going to
boost a parent node that it should be connected to other paragraphs, at least for the first n paragraphs
so we'll want to make sure that the next sibling is a paragraph and has at least some substantial weight to it

@param Element $node

@return bool
A lot of times the first paragraph might be the caption under an image so we ll want to make sure if we re going to boost a parent node that it should be connected to other paragraphs at least for the first n paragraphs so we ll want to make sure that the next sibling is a paragraph and has at least some substantial weight to it