Skip to content

Commit

Permalink
Merge pull request #1 from spatie/analysis-qoQDEQ
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
freekmurze authored Jan 7, 2017
2 parents 0e6224b + 4dca131 commit cb469de
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Exceptions/CannotRenderChild.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Exception;
use Spatie\Html\BaseElement;

class childMustBeABaseElementOrAString extends Exception
class CannotRenderChild extends Exception
{
/**
* @param mixed $child
Expand All @@ -14,6 +14,6 @@ class childMustBeABaseElementOrAString extends Exception
*/
public static function childMustBeAnElementOrAString($child)
{
return new static('The given child should be a ' . BaseElement::class . ' or a string');
return new static('The given child should be a '.BaseElement::class.' or a string');
}
}
}
3 changes: 1 addition & 2 deletions src/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Attributes
public function setAttributes(array $attributes)
{
foreach ($attributes as $attribute => $value) {

if ($attribute === 'class') {
$this->addClass($value);
continue;
Expand Down Expand Up @@ -66,7 +65,7 @@ public function forgetAttribute(string $attribute)
*/
public function addClass($class)
{
if (!is_array($class)) {
if (! is_array($class)) {
$class = [$class];
}

Expand Down
8 changes: 3 additions & 5 deletions src/BaseElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class BaseElement

public function __construct()
{
if (!$this->tag) {
if (! $this->tag) {
throw new Exception;
}

Expand Down Expand Up @@ -70,8 +70,6 @@ public function setChildren($children)
return $element;
}



public function renderChildren(): string
{
return implode('', array_map(function ($child) {
Expand All @@ -92,7 +90,7 @@ public function renderChildren(): string
public function open(): string
{
return $this->attributes->isEmpty()
? '<' . $this->tag . '>'
? '<'.$this->tag.'>'
: "<{$this->tag} {$this->attributes->render()}>";
}

Expand All @@ -105,7 +103,7 @@ public function close(): string

public function render(): string
{
return $this->open() . $this->renderChildren() . $this->close();
return $this->open().$this->renderChildren().$this->close();
}

public function isVoidElement(): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Elements/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Spatie\Html\Elements;

use Exception;
use Spatie\Html\BaseElement;
use Spatie\Html\Html;
use Spatie\Html\BaseElement;

class Select extends BaseElement
{
Expand Down
2 changes: 1 addition & 1 deletion src/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Spatie\Html;

use Spatie\Html\Elements\Element;
use Spatie\Html\Elements\Option;
use Spatie\Html\Elements\Select;
use Spatie\Html\Elements\Element;

class Html
{
Expand Down
4 changes: 1 addition & 3 deletions tests/Elements/SelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function it_can_render_an_empty_version_itself()
/** @test */
public function it_can_be_converted_to_a_string()
{
$this->assertSameHtml('<select></select>', (string)(new Select()));
$this->assertSameHtml('<select></select>', (string) (new Select()));
}

/** @test */
Expand All @@ -26,6 +26,4 @@ public function it_can_render_options()
<option value="option1">value1</option>
</select>', (new Select())->options(['option1' => 'value1'])->render());
}


}
6 changes: 3 additions & 3 deletions tests/Html/SelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SelectTest extends TestCase
/** @test */
public function it_can_render_a_select_element()
{
$this->assertSameHtml('<select></select>',(string)Html::select());
$this->assertSameHtml('<select></select>', (string) Html::select());
}

/** @test */
Expand All @@ -26,6 +26,6 @@ public function it_can_render_a_select_element_with_options()
<option value="option1">value1</option>
<option value="option2">value2</option>
</select>',
(string)Html::select($options));
(string) Html::select($options));
}
}
}
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Spatie\Html\Test;

use DOMDocument;
use DOMElement;
use DOMDocument;
use PHPUnit_Framework_TestCase;

class TestCase extends PHPUnit_Framework_TestCase
Expand Down

0 comments on commit cb469de

Please sign in to comment.