');
$toRemove = true;
} elseif ($input > floor($p / 3)) {
@@ -1364,12 +1364,12 @@ class Readability implements LoggerAwareInterface
$this->logger->debug(' content length less than 10 chars and 0 images, or more than 2 images');
$toRemove = true;
} elseif ($weight < 25 && $linkDensity > 0.2) {
- $this->logger->debug(' weight is '.$weight.' lower than 0 and link density is '.sprintf('%.2f', $linkDensity).' > 0.2');
+ $this->logger->debug(' weight is ' . $weight . ' lower than 0 and link density is ' . sprintf('%.2f', $linkDensity) . ' > 0.2');
$toRemove = true;
} elseif ($weight >= 25 && $linkDensity > 0.5) {
- $this->logger->debug(' weight above 25 but link density is '.sprintf('%.2f', $linkDensity).' > 0.5');
+ $this->logger->debug(' weight above 25 but link density is ' . sprintf('%.2f', $linkDensity) . ' > 0.5');
$toRemove = true;
- } elseif (($embedCount == 1 && $contentLength < 75) || $embedCount > 1) {
+ } elseif (($embedCount === 1 && $contentLength < 75) || $embedCount > 1) {
$this->logger->debug(' 1 embed and content length smaller than 75 chars, or more than one embed');
$toRemove = true;
}
@@ -1391,7 +1391,7 @@ class Readability implements LoggerAwareInterface
public function cleanHeaders($e)
{
for ($headerIndex = 1; $headerIndex < 3; ++$headerIndex) {
- $headers = $e->getElementsByTagName('h'.$headerIndex);
+ $headers = $e->getElementsByTagName('h' . $headerIndex);
for ($i = $headers->length - 1; $i >= 0; --$i) {
if ($this->getWeight($headers->item($i)) < 0 || $this->getLinkDensity($headers->item($i)) > 0.33) {
diff --git a/tests/ReadabilityTest.php b/tests/ReadabilityTest.php
index 90932e7..cb9ceca 100644
--- a/tests/ReadabilityTest.php
+++ b/tests/ReadabilityTest.php
@@ -2,9 +2,9 @@
namespace Tests\Readability;
-use Readability\Readability;
-use Monolog\Logger;
use Monolog\Handler\TestHandler;
+use Monolog\Logger;
+use Readability\Readability;
class ReadabilityTest extends \PHPUnit_Framework_TestCase
{
@@ -94,7 +94,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testInitDivP()
{
- $readability = $this->getReadability(''.str_repeat('
This is the awesome content :)
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('
This is the awesome content :)
', 7) . '
', 'http://0.0.0.0');
$res = $readability->init();
$this->assertTrue($res);
@@ -107,7 +107,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testInitDiv()
{
- $readability = $this->getReadability(''.str_repeat('This is the awesome content :)', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('This is the awesome content :)', 7) . '
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -121,7 +121,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithFootnotes()
{
- $readability = $this->getReadability(''.str_repeat('
This is an awesome text with some links, here there are: the awesome
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('
This is an awesome text with some links, here there are: the awesome
', 7) . '
', 'http://0.0.0.0');
$readability->debug = true;
$readability->convertLinksToFootnotes = true;
$res = $readability->init();
@@ -138,7 +138,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testStandardClean()
{
- $readability = $this->getReadability('', 'http://0.0.0.0');
+ $readability = $this->getReadability('', 'http://0.0.0.0');
$readability->debug = true;
$readability->lightClean = false;
$res = $readability->init();
@@ -155,7 +155,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithIframe()
{
- $readability = $this->getReadability('Title '.str_repeat('
This is an awesome text with some links, here there are: the awesome
', 7).'
This is an awesome text with some links, here there are VIDEO
', 'http://0.0.0.0');
+ $readability = $this->getReadability('Title ' . str_repeat('
This is an awesome text with some links, here there are: the awesome
', 7) . '
This is an awesome text with some links, here there are VIDEO
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -170,7 +170,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithArticle()
{
- $readability = $this->getReadability(''.str_repeat('This is an awesome text with some links, here there are: the awesome', 20).'
This is an awesome text with some links, here there are VIDEO
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('This is an awesome text with some links, here there are: the awesome', 20) . '
This is an awesome text with some links, here there are VIDEO
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -185,7 +185,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithAside()
{
- $readability = $this->getReadability(''.str_repeat('This is an awesome text with some links, here there are: the awesome
', 7).' ', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('This is an awesome text with some links, here there are: the awesome
', 7) . ' ', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -200,7 +200,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithClasses()
{
- $readability = $this->getReadability(''.str_repeat('This is an awesome text with some links, here there are: the awesome
', 7).''.str_repeat('
This text should be removed
', 10).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('This is an awesome text with some links, here there are: the awesome
', 7) . '' . str_repeat('
This text should be removed
', 10) . '
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -215,7 +215,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithClassesWithoutLightClean()
{
- $readability = $this->getReadability(''.str_repeat('This is an awesome text with some links, here there are: the awesome
', 7).''.str_repeat('
This text should be removed
', 10).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('This is an awesome text with some links, here there are: the awesome
', 7) . '' . str_repeat('
This text should be removed
', 10) . '
', 'http://0.0.0.0');
$readability->debug = true;
$readability->lightClean = false;
$res = $readability->init();
@@ -231,7 +231,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithTd()
{
- $readability = $this->getReadability(''.str_repeat('This is an awesome text with some links, here there are the awesome
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('This is an awesome text with some links, here there are the awesome
', 7) . '
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -244,7 +244,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithSameClasses()
{
- $readability = $this->getReadability(''.str_repeat('This is an awesome text with some links, here there are the awesome
', 7).'This text is also an awesome text and you should know that !
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('This is an awesome text with some links, here there are the awesome
', 7) . 'This text is also an awesome text and you should know that !
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -258,7 +258,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithScript()
{
- $readability = $this->getReadability(''.str_repeat('This is an awesome text with some links, here there are the awesome
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('This is an awesome text with some links, here there are the awesome
', 7) . '
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -272,7 +272,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitle()
{
- $readability = $this->getReadability('this is my title '.str_repeat('This is an awesome text with some links, here there are the awesome
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('this is my title ' . str_repeat('This is an awesome text with some links, here there are the awesome
', 7) . '
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -286,7 +286,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitleWithDash()
{
- $readability = $this->getReadability(' title2 - title3 '.str_repeat('This is an awesome text with some links, here there are the awesome
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability(' title2 - title3 ' . str_repeat('This is an awesome text with some links, here there are the awesome
', 7) . '
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -300,7 +300,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitleWithDoubleDot()
{
- $readability = $this->getReadability(' title2 : title3 '.str_repeat('This is an awesome text with some links, here there are the awesome
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability(' title2 : title3 ' . str_repeat('This is an awesome text with some links, here there are the awesome
', 7) . '
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -314,7 +314,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitleTooShortUseH1()
{
- $readability = $this->getReadability('too short this is my h1 title ! '.str_repeat('This is an awesome text with some links, here there are the awesome
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('too short this is my h1 title ! ' . str_repeat('This is an awesome text with some links, here there are the awesome
', 7) . '
', 'http://0.0.0.0');
$readability->debug = true;
$res = $readability->init();
@@ -383,7 +383,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
}
/**
- * This should generate an Exception "DOMElement::setAttribute(): ID post-60 already defined"
+ * This should generate an Exception "DOMElement::setAttribute(): ID post-60 already defined".
*/
public function testAppendIdAlreadyHere()
{
@@ -443,7 +443,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testPostFilters()
{
- $readability = $this->getReadability(''.str_repeat('
This is the awesome content :)
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('
This is the awesome content :)
', 7) . '
', 'http://0.0.0.0');
$readability->addPostFilter('!]*>(.*?) !is', '');
$res = $readability->init();
@@ -456,7 +456,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
{
$this->markTestSkipped('Won\'t work until loadHtml() is moved in init() instead of __construct()');
- $readability = $this->getReadability(''.str_repeat('
This is the awesome and WONDERFUL content :)
', 7).'
', 'http://0.0.0.0');
+ $readability = $this->getReadability('' . str_repeat('
This is the awesome and WONDERFUL content :)
', 7) . '
', 'http://0.0.0.0');
$readability->addPreFilter('!]*>(.*?) !is', '');
$res = $readability->init();