From fd3f9619f210cb7cdf6a43c139affe77d017f58f Mon Sep 17 00:00:00 2001 From: Marc Guinea Date: Wed, 8 Aug 2018 13:30:59 +0000 Subject: [PATCH] Apply fixes from StyleCI [ci skip] [skip ci] --- src/Contracts/Robots.php | 14 +++++++------- src/Facades/Robots.php | 4 +--- src/Robots.php | 22 ++++++++++++++-------- tests/TestCase.php | 5 ++--- tests/Unit/RobotsFacadeTest.php | 14 ++++++-------- tests/Unit/RobotsTest.php | 14 ++++++-------- tests/bootstrap.php | 2 +- 7 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/Contracts/Robots.php b/src/Contracts/Robots.php index 51aa645..28a5824 100644 --- a/src/Contracts/Robots.php +++ b/src/Contracts/Robots.php @@ -4,13 +4,13 @@ interface Robots { - /** - * Add a allow rule to the robots. - * - * @param string|array $directories - * @return \Robots\Contracts\Robot; - */ - public function addAllow(string $directories): self; + /** + * Add a allow rule to the robots. + * + * @param string|array $directories + * @return \Robots\Contracts\Robot; + */ + public function addAllow(string $directories): self; /** * Add a comment to the robots. diff --git a/src/Facades/Robots.php b/src/Facades/Robots.php index 89182c9..b90ae43 100644 --- a/src/Facades/Robots.php +++ b/src/Facades/Robots.php @@ -5,9 +5,7 @@ use Illuminate\Support\Facades\Facade; /** - * Class RobotsFacade - * - * @package Robots + * Class RobotsFacade. */ class Robots extends Facade { diff --git a/src/Robots.php b/src/Robots.php index a7c9929..eec1ca2 100644 --- a/src/Robots.php +++ b/src/Robots.php @@ -7,11 +7,11 @@ class Robots implements RobotsContract { /** - * The rows of for the robots + * The rows of for the robots. * * @var array */ - protected $rows = array(); + protected $rows = []; /** * Add a allow rule to the robots. @@ -22,6 +22,7 @@ class Robots implements RobotsContract public function addAllow($directories): RobotsContract { $this->addRuleLine($directories, 'Allow'); + return $this; } @@ -34,6 +35,7 @@ public function addAllow($directories): RobotsContract public function addComment($comment): RobotsContract { $this->addLine("# $comment"); + return $this; } @@ -46,6 +48,7 @@ public function addComment($comment): RobotsContract public function addDisallow($directories): RobotsContract { $this->addRuleLine($directories, 'Disallow'); + return $this; } @@ -58,6 +61,7 @@ public function addDisallow($directories): RobotsContract public function addHost($host): RobotsContract { $this->addLine("Host: $host"); + return $this; } @@ -78,8 +82,7 @@ protected function addLine($row) */ protected function addRows($rows) { - foreach ((array) $rows as $row) - { + foreach ((array) $rows as $row) { $this->addLine($row); } } @@ -92,8 +95,7 @@ protected function addRows($rows) */ protected function addRuleLine($directories, $rule) { - foreach ((array) $directories as $directory) - { + foreach ((array) $directories as $directory) { $this->addLine("$rule: $directory"); } } @@ -107,6 +109,7 @@ protected function addRuleLine($directories, $rule) public function addSitemap($sitemap): RobotsContract { $this->addLine("Sitemap: $sitemap"); + return $this; } @@ -116,7 +119,8 @@ public function addSitemap($sitemap): RobotsContract */ public function addSpacer(): RobotsContract { - $this->addLine(""); + $this->addLine(''); + return $this; } @@ -129,6 +133,7 @@ public function addSpacer(): RobotsContract public function addUserAgent($userAgent): RobotsContract { $this->addLine("User-agent: $userAgent"); + return $this; } @@ -149,7 +154,8 @@ public function generate(): string */ public function reset(): RobotsContract { - $this->rows = array(); + $this->rows = []; + return $this; } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 5cec9fd..806a443 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,9 +2,8 @@ namespace Robots\Tests; -use Illuminate\Database\Schema\Blueprint; -use Orchestra\Testbench\TestCase as Orchestra; use Robots\Robots; +use Orchestra\Testbench\TestCase as Orchestra; abstract class TestCase extends Orchestra { @@ -26,7 +25,7 @@ public function setUp() protected function getPackageProviders($app) { return [ - \Robots\RobotsServiceProvider::class + \Robots\RobotsServiceProvider::class, ]; } } diff --git a/tests/Unit/RobotsFacadeTest.php b/tests/Unit/RobotsFacadeTest.php index 2da4a2d..74d1007 100644 --- a/tests/Unit/RobotsFacadeTest.php +++ b/tests/Unit/RobotsFacadeTest.php @@ -2,7 +2,6 @@ namespace Robots\Tests; -use Illuminate\Foundation\Testing\WithoutMiddleware; use Robots\Facades\Robots; class RobotsFacadeTest extends TestCase @@ -30,14 +29,13 @@ public function testAddAllows() $this->assertEquals("Allow: foo\nAllow: bar", Robots::generate()); } - public function testFacadeAddComments() { Robots::reset(); Robots::addComment('foo'); - $this->assertEquals('# foo', Robots::generate()); + $this->assertEquals('# foo', Robots::generate()); } public function testFacadeAddDisallow() @@ -46,7 +44,7 @@ public function testFacadeAddDisallow() Robots::addDisallow('foo'); - $this->assertEquals('Disallow: foo', Robots::generate()); + $this->assertEquals('Disallow: foo', Robots::generate()); } public function testAddDisallows() @@ -64,7 +62,7 @@ public function testFacadeAddHost() Robots::addHost('foo'); - $this->assertEquals('Host: foo', Robots::generate()); + $this->assertEquals('Host: foo', Robots::generate()); } public function testFacadeAddSitemap() @@ -73,7 +71,7 @@ public function testFacadeAddSitemap() Robots::addSitemap('foo'); - $this->assertEquals('Sitemap: foo', Robots::generate()); + $this->assertEquals('Sitemap: foo', Robots::generate()); } public function testFacadeAddSpacer() @@ -82,7 +80,7 @@ public function testFacadeAddSpacer() Robots::addSpacer(); - $this->assertEquals('', Robots::generate()); + $this->assertEquals('', Robots::generate()); } public function testFacadeAddUserAgent() @@ -91,6 +89,6 @@ public function testFacadeAddUserAgent() Robots::addUserAgent('foo'); - $this->assertEquals('User-agent: foo', Robots::generate()); + $this->assertEquals('User-agent: foo', Robots::generate()); } } diff --git a/tests/Unit/RobotsTest.php b/tests/Unit/RobotsTest.php index e5a0a8d..16c898d 100644 --- a/tests/Unit/RobotsTest.php +++ b/tests/Unit/RobotsTest.php @@ -2,8 +2,6 @@ namespace Robots\Tests; -use Illuminate\Foundation\Testing\WithoutMiddleware; - class RobotsTest extends TestCase { public function setUp() @@ -35,7 +33,7 @@ public function testAddComments() $this->robots->addComment('foo'); - $this->assertEquals('# foo', $this->robots->generate()); + $this->assertEquals('# foo', $this->robots->generate()); } public function testAddDisallow() @@ -44,7 +42,7 @@ public function testAddDisallow() $this->robots->addDisallow('foo'); - $this->assertEquals('Disallow: foo', $this->robots->generate()); + $this->assertEquals('Disallow: foo', $this->robots->generate()); } public function testAddDisallows() @@ -62,7 +60,7 @@ public function testAddHost() $this->robots->addHost('foo'); - $this->assertEquals('Host: foo', $this->robots->generate()); + $this->assertEquals('Host: foo', $this->robots->generate()); } public function testAddSitemap() @@ -71,7 +69,7 @@ public function testAddSitemap() $this->robots->addSitemap('foo'); - $this->assertEquals('Sitemap: foo', $this->robots->generate()); + $this->assertEquals('Sitemap: foo', $this->robots->generate()); } public function testAddSpacer() @@ -80,7 +78,7 @@ public function testAddSpacer() $this->robots->addSpacer(); - $this->assertEquals('', $this->robots->generate()); + $this->assertEquals('', $this->robots->generate()); } public function testAddUserAgent() @@ -89,7 +87,7 @@ public function testAddUserAgent() $this->robots->addUserAgent('foo'); - $this->assertEquals('User-agent: foo', $this->robots->generate()); + $this->assertEquals('User-agent: foo', $this->robots->generate()); } public function testConcatenate() diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d21c14d..991ea43 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,3 +1,3 @@