From ee754d5a7b184fb66ad57b660fdcbdf691f29bce Mon Sep 17 00:00:00 2001 From: Andres Rey Date: Tue, 18 Oct 2016 16:13:19 +0000 Subject: Applied fixes from StyleCI --- src/DOMElement.php | 10 ++++------ src/DOMElementInterface.php | 2 +- src/HTMLParser.php | 15 ++++++--------- src/Readability.php | 5 +++-- src/ReadabilityInterface.php | 1 - 5 files changed, 14 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/DOMElement.php b/src/DOMElement.php index 728aa65..8e7456d 100644 --- a/src/DOMElement.php +++ b/src/DOMElement.php @@ -5,14 +5,11 @@ namespace andreskrey\Readability; use League\HTMLToMarkdown\Element; /** - * Class DOMElement + * Class DOMElement. * * This is a extension of the original Element class from League\HTMLToMarkdown\Element. * This class adds functions specific to Readability.php and overloads some of them to fit the purpose of this project. - * - * @package andreskrey\Readability */ - class DOMElement extends Element implements DOMElementInterface { /** @@ -21,7 +18,7 @@ class DOMElement extends Element implements DOMElementInterface protected $node; /** - * Constructor + * Constructor. * * @param \DOMNode $node Selected element from DOMDocument */ @@ -73,6 +70,7 @@ class DOMElement extends Element implements DOMElementInterface * Get the ancestors of the current node. * * @param int $maxLevel Max amount of ancestors to get. + * * @return array */ public function getNodeAncestors($maxLevel = 3) @@ -103,7 +101,7 @@ class DOMElement extends Element implements DOMElementInterface public function getParent() { $node = $this->node->parentNode; + return ($node) ? new static($node) : null; } - } diff --git a/src/DOMElementInterface.php b/src/DOMElementInterface.php index 0241b6a..17c14dd 100644 --- a/src/DOMElementInterface.php +++ b/src/DOMElementInterface.php @@ -19,7 +19,7 @@ interface DOMElementInterface extends ElementInterface public function hasSinglePNode(); /** - * @return integer + * @return int */ public function getNodeAncestors(); } diff --git a/src/HTMLParser.php b/src/HTMLParser.php index c4d102c..c396043 100644 --- a/src/HTMLParser.php +++ b/src/HTMLParser.php @@ -5,10 +5,9 @@ namespace andreskrey\Readability; use DOMDocument; /** - * Class HTMLParser + * Class HTMLParser. * * A helper class to parse HTML and get a Readability object. - * */ class HTMLParser { @@ -46,12 +45,11 @@ class HTMLParser 'nextLink' => '/(next|weiter|continue|>([^\|]|$)|»([^\|]|$))/i', 'prevLink' => '/(prev|earl|old|new|<|«)/i', 'whitespace' => '/^\s*$/', - 'hasContent' => '/\S$/' + 'hasContent' => '/\S$/', ]; /** - * Constructor - * + * Constructor. */ public function __construct() { @@ -62,7 +60,7 @@ class HTMLParser } /** - * Parse the html. This is the main entry point of the HTMLParser + * Parse the html. This is the main entry point of the HTMLParser. * * @param string $html Full html of the website, page, etc. * @@ -116,7 +114,7 @@ class HTMLParser } /** - * Tries to guess relevant info from metadata of the html + * Tries to guess relevant info from metadata of the html. * * @return array Metadata info. May have title, excerpt and or byline. */ @@ -124,7 +122,7 @@ class HTMLParser { $metadata = []; foreach ($this->dom->getElementsByTagName('meta') as $meta) { - /** @var DOMElement $meta */ + /* @var DOMElement $meta */ $name = $meta->getAttribute('name'); $property = $meta->getAttribute('property'); @@ -241,7 +239,6 @@ class HTMLParser $readability = new Readability($ancestor); $candidates[] = $readability->initializeNode(); } - } } } diff --git a/src/Readability.php b/src/Readability.php index a53d032..bab7c42 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -23,7 +23,7 @@ class Readability implements ReadabilityInterface ]; /** - * Constructor + * Constructor. * * @param DOMElement $node */ @@ -78,9 +78,10 @@ class Readability implements ReadabilityInterface } /** - * Calculates the weight of the class/id of the current element + * Calculates the weight of the class/id of the current element. * * @todo check for flag that lets this function run or not + * * @return int */ public function getClassWeight() diff --git a/src/ReadabilityInterface.php b/src/ReadabilityInterface.php index cbb4cb2..21b78e5 100644 --- a/src/ReadabilityInterface.php +++ b/src/ReadabilityInterface.php @@ -23,5 +23,4 @@ interface ReadabilityInterface * @return int */ public function getClassWeight(); - } -- cgit v1.2.3