src/Nodes/NodeTrait.php
public function getLinkDensity()
    {
        $linkLength = 0;
        $textLength = mb_strlen($this->getTextContent(true));

        if (!$textLength) {
            return 0;
        }

        $links = $this->getAllLinks();

        if ($links) {
            /** @var DOMElement $link */
            foreach ($links as $link) {
                $linkLength += mb_strlen($link->getTextContent(true));
            }
        }

        return $linkLength / $textLength;
    }
public function getLinkDensity()
    {
        $linkLength = 0;
        $textLength = mb_strlen($this->getTextContent(true));

        if (!$textLength) {
            return 0;
        }

        $links = $this->getAllLinks();

        if ($links) {
            /** @var DOMElement $link */
            foreach ($links as $link) {
                $linkLength += mb_strlen($link->getTextContent(true));
            }
        }

        return $linkLength / $textLength;
    }
public function getLinkDensity ( ) { $ linkLength = 0 ; $ textLength = mb_strlen ( $ this -> getTextContent ( true ) ) ; if ( ! $ textLength ) { return 0 ; } $ links = $ this -> getAllLinks ( ) ; if ( $ links ) { /** @var DOMElement $link */ foreach ( $ links as $ link ) { $ linkLength += mb_strlen ( $ link -> getTextContent ( true ) ) ; } } return $ linkLength / $ textLength ; }
Get the density of links as a percentage of the content
This is the amount of text that is inside a link divided by the total text in the node.

@return int
Get the density of links as a percentage of the content This is the amount of text that is inside a link divided by the total text in the node .