summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2017-12-01 17:17:19 +0000
committerStyleCI Bot <[email protected]>2017-12-01 17:17:19 +0000
commit995d6fb8045bbbebfe8578f86431aa522985ee6e (patch)
tree1f78f7ad34992c4502f0e9153aced92ac4b1ae76 /src
parent35f81ed82beffcacbaa3e2937e90a8cf30b4f9ec (diff)
Apply fixes from StyleCI
Diffstat (limited to 'src')
-rw-r--r--src/Configuration.php26
-rw-r--r--src/NodeClass/DOMDocument.php2
-rw-r--r--src/NodeClass/DOMNode.php3
-rw-r--r--src/NodeClass/NodeClassTrait.php9
-rw-r--r--src/NodeUtility.php15
-rw-r--r--src/Readability.php36
6 files changed, 46 insertions, 45 deletions
diff --git a/src/Configuration.php b/src/Configuration.php
index 6ce8b5b..1a405de 100644
--- a/src/Configuration.php
+++ b/src/Configuration.php
@@ -3,7 +3,7 @@
namespace andreskrey\Readability;
/**
- * Class Configuration
+ * Class Configuration.
*/
class Configuration
{
@@ -62,11 +62,13 @@ class Configuration
/**
* @param int $maxTopCandidates
+ *
* @return $this
*/
public function setMaxTopCandidates($maxTopCandidates)
{
$this->maxTopCandidates = $maxTopCandidates;
+
return $this;
}
@@ -80,11 +82,13 @@ class Configuration
/**
* @param int $wordThreshold
+ *
* @return $this
*/
public function setWordThreshold($wordThreshold)
{
$this->wordThreshold = $wordThreshold;
+
return $this;
}
@@ -98,11 +102,13 @@ class Configuration
/**
* @param bool $articleByLine
+ *
* @return $this
*/
public function setArticleByLine($articleByLine)
{
$this->articleByLine = $articleByLine;
+
return $this;
}
@@ -116,11 +122,13 @@ class Configuration
/**
* @param bool $stripUnlikelyCandidates
+ *
* @return $this
*/
public function setStripUnlikelyCandidates($stripUnlikelyCandidates)
{
$this->stripUnlikelyCandidates = $stripUnlikelyCandidates;
+
return $this;
}
@@ -134,11 +142,13 @@ class Configuration
/**
* @param bool $cleanConditionally
+ *
* @return $this
*/
public function setCleanConditionally($cleanConditionally)
{
$this->cleanConditionally = $cleanConditionally;
+
return $this;
}
@@ -152,11 +162,13 @@ class Configuration
/**
* @param bool $weightClasses
+ *
* @return $this
*/
public function setWeightClasses($weightClasses)
{
$this->weightClasses = $weightClasses;
+
return $this;
}
@@ -170,11 +182,13 @@ class Configuration
/**
* @param bool $removeReadabilityTags
+ *
* @return $this
*/
public function setRemoveReadabilityTags($removeReadabilityTags)
{
$this->removeReadabilityTags = $removeReadabilityTags;
+
return $this;
}
@@ -188,11 +202,13 @@ class Configuration
/**
* @param bool $fixRelativeURLs
+ *
* @return $this
*/
public function setFixRelativeURLs($fixRelativeURLs)
{
$this->fixRelativeURLs = $fixRelativeURLs;
+
return $this;
}
@@ -206,11 +222,13 @@ class Configuration
/**
* @param bool $substituteEntities
+ *
* @return $this
*/
public function setSubstituteEntities($substituteEntities)
{
$this->substituteEntities = $substituteEntities;
+
return $this;
}
@@ -224,11 +242,13 @@ class Configuration
/**
* @param bool $normalizeEntities
+ *
* @return $this
*/
public function setNormalizeEntities($normalizeEntities)
{
$this->normalizeEntities = $normalizeEntities;
+
return $this;
}
@@ -242,11 +262,13 @@ class Configuration
/**
* @param string $originalURL
+ *
* @return $this
*/
public function setOriginalURL($originalURL)
{
$this->originalURL = $originalURL;
+
return $this;
}
@@ -260,11 +282,13 @@ class Configuration
/**
* @param bool $summonCthulhu
+ *
* @return $this
*/
public function setSummonCthulhu($summonCthulhu)
{
$this->summonCthulhu = $summonCthulhu;
+
return $this;
}
diff --git a/src/NodeClass/DOMDocument.php b/src/NodeClass/DOMDocument.php
index f379268..98b1215 100644
--- a/src/NodeClass/DOMDocument.php
+++ b/src/NodeClass/DOMDocument.php
@@ -14,7 +14,7 @@ class DOMDocument extends \DOMDocument
$this->registerNodeClass('DOMCdataSection', DOMCdataSection::class);
$this->registerNodeClass('DOMCharacterData', DOMCharacterData::class);
$this->registerNodeClass('DOMComment', DOMComment::class);
- $this->registerNodeClass('DOMDocument', DOMDocument::class);
+ $this->registerNodeClass('DOMDocument', self::class);
$this->registerNodeClass('DOMDocumentFragment', DOMDocumentFragment::class);
$this->registerNodeClass('DOMDocumentType', DOMDocumentType::class);
$this->registerNodeClass('DOMElement', DOMElement::class);
diff --git a/src/NodeClass/DOMNode.php b/src/NodeClass/DOMNode.php
index c9ed1c3..eb5e93e 100644
--- a/src/NodeClass/DOMNode.php
+++ b/src/NodeClass/DOMNode.php
@@ -3,10 +3,9 @@
namespace andreskrey\Readability\NodeClass;
/**
- * Class DOMNode
+ * Class DOMNode.
*
* @method getAttribute($attribute)
- * @package andreskrey\Readability\NodeClass
*/
class DOMNode extends \DOMNode
{
diff --git a/src/NodeClass/NodeClassTrait.php b/src/NodeClass/NodeClassTrait.php
index a1382d1..f2df51a 100644
--- a/src/NodeClass/NodeClassTrait.php
+++ b/src/NodeClass/NodeClassTrait.php
@@ -7,14 +7,14 @@ use andreskrey\Readability\NodeUtility;
trait NodeClassTrait
{
/**
- * Content score of the node. Used to determine the value of the content
+ * Content score of the node. Used to determine the value of the content.
*
* @var int
*/
public $contentScore = 0;
/**
- * Flag for initialized status
+ * Flag for initialized status.
*
* @var bool
*/
@@ -38,7 +38,7 @@ trait NodeClassTrait
];
/**
- * initialized getter
+ * initialized getter.
*
* @return bool
*/
@@ -53,6 +53,7 @@ trait NodeClassTrait
* @ TODO: I don't like the weightClasses param. How can we get the config here?
*
* @param $weightClasses bool Weight classes?
+ *
* @return static
*/
public function initializeNode($weightClasses)
@@ -181,7 +182,6 @@ trait NodeClassTrait
return $linkLength / $textLength;
}
-
/**
* Calculates the weight of the class/id of the current element.
*
@@ -283,7 +283,6 @@ trait NodeClassTrait
return ['rows' => $rows, 'columns' => $columns];
}
-
/**
* Creates a new node based on the text content of the original node.
*
diff --git a/src/NodeUtility.php b/src/NodeUtility.php
index d0796dd..7fbdd45 100644
--- a/src/NodeUtility.php
+++ b/src/NodeUtility.php
@@ -7,14 +7,12 @@ use andreskrey\Readability\NodeClass\DOMElement;
use andreskrey\Readability\NodeClass\DOMNode;
/**
- * Class NodeUtility
- * @package andreskrey\Readability
+ * Class NodeUtility.
*/
class NodeUtility
{
-
/**
- * Collection of regexps to check the node usability
+ * Collection of regexps to check the node usability.
*
* @var array
*/
@@ -36,12 +34,11 @@ class NodeUtility
'onlyWhitespace' => '/\x{00A0}|\s+/u'
];
-
/**
- *
- * Imported from the Element class on league\html-to-markdown
+ * Imported from the Element class on league\html-to-markdown.
*
* @param $node
+ *
* @return DOMElement
*/
public static function nextElement($node)
@@ -56,13 +53,13 @@ class NodeUtility
return $next;
}
-
/**
* Changes the node tag name. Since tagName on DOMElement is a read only value, this must be done creating a new
* element with the new tag name and importing it to the main DOMDocument.
*
* @param string $value
* @param bool $importAttributes
+ *
* @return DOMNode
*/
public static function setNodeTag($node, $value, $importAttributes = false)
@@ -72,7 +69,6 @@ class NodeUtility
$children = $node->childNodes;
/** @var $children \DOMNodeList $i */
-
for ($i = 0; $i < $children->length; $i++) {
$import = $new->importNode($children->item($i), true);
$new->firstChild->appendChild($import);
@@ -122,7 +118,6 @@ class NodeUtility
}
}
-
/**
* Returns the next node. First checks for children (if the flag allows it), then for siblings, and finally
* for parents.
diff --git a/src/Readability.php b/src/Readability.php
index c42e577..282e983 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -3,21 +3,12 @@
namespace andreskrey\Readability;
use andreskrey\Readability\NodeClass\DOMDocument;
-use andreskrey\Readability\NodeClass\DOMAttr;
-use andreskrey\Readability\NodeClass\DOMCdataSection;
-use andreskrey\Readability\NodeClass\DOMCharacterData;
-use andreskrey\Readability\NodeClass\DOMComment;
-use andreskrey\Readability\NodeClass\DOMDocumentFragment;
-use andreskrey\Readability\NodeClass\DOMDocumentType;
use andreskrey\Readability\NodeClass\DOMElement;
use andreskrey\Readability\NodeClass\DOMNode;
-use andreskrey\Readability\NodeClass\DOMNotation;
-use andreskrey\Readability\NodeClass\DOMProcessingInstruction;
use andreskrey\Readability\NodeClass\DOMText;
-use andreskrey\Readability\NodeClass\NodeClassTrait;
/**
- * Class Readability
+ * Class Readability.
*/
class Readability
{
@@ -29,49 +20,49 @@ class Readability
protected $dom;
/**
- * Title of the article
+ * Title of the article.
*
* @var string|null
*/
protected $title = null;
/**
- * HTML content article
+ * HTML content article.
*
* @var string|null
*/
protected $content = null;
/**
- * Excerpt of the article
+ * Excerpt of the article.
*
* @var string|null
*/
protected $excerpt = null;
/**
- * Main image of the article
+ * Main image of the article.
*
* @var string|null
*/
protected $image = null;
/**
- * Author of the article. Extracted from the byline tags and other social media properties
+ * Author of the article. Extracted from the byline tags and other social media properties.
*
* @var string|null
*/
protected $author = null;
/**
- * Direction of the text
+ * Direction of the text.
*
* @var string|null
*/
protected $direction = null;
/**
- * Configuration object
+ * Configuration object.
*
* @var Configuration
*/
@@ -116,7 +107,7 @@ class Readability
}
/**
- * Main parse function
+ * Main parse function.
*
* @param $html
*
@@ -229,7 +220,7 @@ class Readability
}
/**
- * Tries to guess relevant info from metadata of the html. Sets the results in the Readability properties
+ * Tries to guess relevant info from metadata of the html. Sets the results in the Readability properties.
*/
private function getMetadata()
{
@@ -326,7 +317,6 @@ class Readability
return $result;
}
-
/**
* Tries to get the main article image. Will only update the metadata if the getMetadata function couldn't
* find a correct image.
@@ -447,7 +437,6 @@ class Readability
return $curTitle;
}
-
private function toAbsoluteURI($uri)
{
list($pathBase, $scheme, $prePath) = $this->getPathInfo($this->configuration->getOriginalURL());
@@ -495,7 +484,6 @@ class Readability
return [$pathBase, $scheme, $prePath];
}
-
/**
* Gets nodes from the root element.
*
@@ -641,7 +629,6 @@ class Readability
return false;
}
-
/**
* Removes all the scripts of the html.
*
@@ -735,7 +722,6 @@ class Readability
}
}
-
/**
* Assign scores to each node. This function will rate each node and return a DOMElement object for each one.
*
@@ -1147,7 +1133,6 @@ class Readability
}
}
-
/**
* Remove the style attribute on every e and under.
* TODO: To be moved to Readability.
@@ -1417,7 +1402,6 @@ class Readability
return $article;
}
-
/**
* @return null|string
*/