diff options
author | Andres Rey <[email protected]> | 2017-11-30 20:06:45 +0000 |
---|---|---|
committer | Andres Rey <[email protected]> | 2017-11-30 20:06:45 +0000 |
commit | fc4834c588c61ab42b89e3324fa01d467f4a8d00 (patch) | |
tree | 188d5a03b43a385a7e7ec71b204b8d3a840c0370 /src | |
parent | 89555a061f7166a85c2a8ea0a7176067990c64a3 (diff) |
Remove duplicated functions
Diffstat (limited to 'src')
-rw-r--r-- | src/NodeClass/NodeClassTrait.php | 2 | ||||
-rw-r--r-- | src/NodeUtility.php | 18 | ||||
-rw-r--r-- | src/Readability.php | 2 |
3 files changed, 2 insertions, 20 deletions
diff --git a/src/NodeClass/NodeClassTrait.php b/src/NodeClass/NodeClassTrait.php index 678b41e..1446fb6 100644 --- a/src/NodeClass/NodeClassTrait.php +++ b/src/NodeClass/NodeClassTrait.php @@ -229,7 +229,7 @@ trait NodeClassTrait */ public function createNode($originalNode, $tagName) { - $text = NodeUtility::getTextContent($originalNode); + $text = $originalNode->getTextContent(); $newNode = $originalNode->ownerDocument->createElement($tagName, $text); return $newNode; diff --git a/src/NodeUtility.php b/src/NodeUtility.php index ca34c8c..07bc8da 100644 --- a/src/NodeUtility.php +++ b/src/NodeUtility.php @@ -225,22 +225,4 @@ class NodeUtility return $result; } - - /** - * Returns the full text of the node. - * - * @param $node DOMNode|DOMElement - * @param bool $normalize Normalize white space? - * @return string - */ - public static function getTextContent($node, $normalize = false) - { - $nodeValue = $node->nodeValue; - if ($normalize) { - $nodeValue = trim(preg_replace('/\s{2,}/', ' ', $nodeValue)); - } - - return $nodeValue; - } - } diff --git a/src/Readability.php b/src/Readability.php index b80641e..1cd7c1f 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -555,7 +555,7 @@ class Readability // EXPERIMENTAL foreach ($node->getChildren() as $child) { /** @var $child DOMNode */ - if ($child->nodeType === XML_TEXT_NODE && mb_strlen(trim(NodeUtility::getTextContent($child))) > 0) { + if ($child->nodeType === XML_TEXT_NODE && mb_strlen(trim($child->getTextContent())) > 0) { $newNode = $node->createNode($child, 'p'); $child->parentNode->replaceChild($newNode, $child); } |