Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #41 from spatie/analysis-XavaJm
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
freekmurze authored Oct 4, 2018
2 parents c5a0333 + b5867dc commit 6e78113
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/BladeXCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function componentStartString(BladeXComponent $bladeXComponent, array
}

if ($bladeXComponent->viewModel) {
$componentAttributeString = "
$componentAttributeString = "
array_merge(
app(Spatie\BladeX\ContextStack::class)->read(),
{$componentAttributeString},
Expand Down
7 changes: 3 additions & 4 deletions src/BladeXComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Closure;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Str;
use Spatie\BladeX\Exceptions\CouldNotRegisterBladeXComponent;

class BladeXComponent
Expand Down Expand Up @@ -33,7 +32,7 @@ public function __construct(string $bladeViewName, string $name = '')
$name = kebab_case(end($baseComponentName));
}

if (!view()->exists($bladeViewName)) {
if (! view()->exists($bladeViewName)) {
throw CouldNotRegisterBladeXComponent::viewNotFound($bladeViewName, $name);
}

Expand All @@ -55,11 +54,11 @@ public function viewModel($viewModel)
return $this;
}

if (!class_exists($viewModel)) {
if (! class_exists($viewModel)) {
throw CouldNotRegisterBladeXComponent::viewModelNotFound($this->name, $viewModel);
}

if (!is_a($viewModel, Arrayable::class, true)) {
if (! is_a($viewModel, Arrayable::class, true)) {
throw CouldNotRegisterBladeXComponent::viewModelNotArrayable($this->name, $viewModel);
}

Expand Down
12 changes: 5 additions & 7 deletions tests/Features/ViewModel/ViewModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Spatie\Snapshots\MatchesSnapshots;
use Spatie\BladeX\Exceptions\CouldNotRegisterBladeXComponent;
use Spatie\BladeX\Tests\Features\ViewModel\TestClasses\DummyViewModel;
use Spatie\BladeX\Tests\Features\ViewModel\TestClasses\SelectFieldViewModel;
use Spatie\BladeX\Tests\Features\ViewModel\TestClasses\InvalidViewModel;
use Spatie\BladeX\Tests\Features\ViewModel\TestClasses\SelectFieldViewModel;

class ViewModelTest extends TestCase
{
Expand Down Expand Up @@ -105,18 +105,18 @@ public function it_can_render_a_component_using_a_view_model()
/** @test */
public function it_can_render_a_component_using_a_closure_based_view_model()
{
BladeX::component('components.select-field')->viewModel(function(
BladeX::component('components.select-field')->viewModel(function (
string $selected) {
return ['isSelected' => function(string $optionName) use ($selected) {
return ['isSelected' => function (string $optionName) use ($selected) {
return $optionName === $selected;
}];
});

$this->assertMatchesViewSnapshot('viewModel');

BladeX::component('components.select-field')->viewModel(function(
BladeX::component('components.select-field')->viewModel(function (
string $selected) {
return ['isSelected' => function(string $optionName) use ($selected) {
return ['isSelected' => function (string $optionName) use ($selected) {
return $optionName === $selected;
}];
});
Expand All @@ -139,6 +139,4 @@ public function it_will_return_an_exception_if_a_view_model_class_does_not_imple

BladeX::component('components.select-field')->viewModel(InvalidViewModel::class);
}


}

0 comments on commit 6e78113

Please sign in to comment.