Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #3

Merged
merged 1 commit into from Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Contracts/Robots.php
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions src/Facades/Robots.php
Expand Up @@ -5,9 +5,7 @@
use Illuminate\Support\Facades\Facade;

/**
* Class RobotsFacade
*
* @package Robots
* Class RobotsFacade.
*/
class Robots extends Facade
{
Expand Down
22 changes: 14 additions & 8 deletions src/Robots.php
Expand Up @@ -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.
Expand All @@ -22,6 +22,7 @@ class Robots implements RobotsContract
public function addAllow($directories): RobotsContract
{
$this->addRuleLine($directories, 'Allow');

return $this;
}

Expand All @@ -34,6 +35,7 @@ public function addAllow($directories): RobotsContract
public function addComment($comment): RobotsContract
{
$this->addLine("# $comment");

return $this;
}

Expand All @@ -46,6 +48,7 @@ public function addComment($comment): RobotsContract
public function addDisallow($directories): RobotsContract
{
$this->addRuleLine($directories, 'Disallow');

return $this;
}

Expand All @@ -58,6 +61,7 @@ public function addDisallow($directories): RobotsContract
public function addHost($host): RobotsContract
{
$this->addLine("Host: $host");

return $this;
}

Expand All @@ -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);
}
}
Expand All @@ -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");
}
}
Expand All @@ -107,6 +109,7 @@ protected function addRuleLine($directories, $rule)
public function addSitemap($sitemap): RobotsContract
{
$this->addLine("Sitemap: $sitemap");

return $this;
}

Expand All @@ -116,7 +119,8 @@ public function addSitemap($sitemap): RobotsContract
*/
public function addSpacer(): RobotsContract
{
$this->addLine("");
$this->addLine('');

return $this;
}

Expand All @@ -129,6 +133,7 @@ public function addSpacer(): RobotsContract
public function addUserAgent($userAgent): RobotsContract
{
$this->addLine("User-agent: $userAgent");

return $this;
}

Expand All @@ -149,7 +154,8 @@ public function generate(): string
*/
public function reset(): RobotsContract
{
$this->rows = array();
$this->rows = [];

return $this;
}
}
5 changes: 2 additions & 3 deletions tests/TestCase.php
Expand Up @@ -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
{
Expand All @@ -26,7 +25,7 @@ public function setUp()
protected function getPackageProviders($app)
{
return [
\Robots\RobotsServiceProvider::class
\Robots\RobotsServiceProvider::class,
];
}
}
14 changes: 6 additions & 8 deletions tests/Unit/RobotsFacadeTest.php
Expand Up @@ -2,7 +2,6 @@

namespace Robots\Tests;

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Robots\Facades\Robots;

class RobotsFacadeTest extends TestCase
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -82,7 +80,7 @@ public function testFacadeAddSpacer()

Robots::addSpacer();

$this->assertEquals('', Robots::generate());
$this->assertEquals('', Robots::generate());
}

public function testFacadeAddUserAgent()
Expand All @@ -91,6 +89,6 @@ public function testFacadeAddUserAgent()

Robots::addUserAgent('foo');

$this->assertEquals('User-agent: foo', Robots::generate());
$this->assertEquals('User-agent: foo', Robots::generate());
}
}
14 changes: 6 additions & 8 deletions tests/Unit/RobotsTest.php
Expand Up @@ -2,8 +2,6 @@

namespace Robots\Tests;

use Illuminate\Foundation\Testing\WithoutMiddleware;

class RobotsTest extends TestCase
{
public function setUp()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -80,7 +78,7 @@ public function testAddSpacer()

$this->robots->addSpacer();

$this->assertEquals('', $this->robots->generate());
$this->assertEquals('', $this->robots->generate());
}

public function testAddUserAgent()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
@@ -1,3 +1,3 @@
<?php

require __DIR__ . '/../vendor/autoload.php';
require __DIR__.'/../vendor/autoload.php';