Skip to content

Commit

Permalink
squash mutants
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen-G committed Jan 26, 2023
1 parent 543c304 commit 49eaf44
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 51 deletions.
3 changes: 3 additions & 0 deletions infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"source": {
"directories": [
"src"
],
"excludes": [
"BladeMacroServiceProvider.php"
]
},
"logs": {
Expand Down
14 changes: 3 additions & 11 deletions src/BladeMacroServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@ class BladeMacroServiceProvider extends ServiceProvider
{
public function boot(): void
{
Blade::directive('macro', function ($macroName) {
return Macro::define($macroName);
});

Blade::directive('endMacro', function () {
return Macro::endDefinition();
});

Blade::directive('showMacro', function ($expression) {
return Macro::show($expression);
});
Blade::directive('macro', fn ($macroName) => Macro::define($macroName));
Blade::directive('endMacro', fn () => Macro::endDefinition());
Blade::directive('showMacro', fn ($expression) => Macro::show($expression));
}
}
3 changes: 2 additions & 1 deletion src/Macro.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Blade;
use InvalidArgumentException;

final class Macro
{
Expand All @@ -22,7 +23,7 @@ public static function show(string $expression): string
$macroName = $arguments->first();

if (!array_key_exists($macroName, self::$macros)) {
throw new \Exception("The `$macroName` macro is not defined.");
throw new InvalidArgumentException("The `$macroName` macro is not defined.");
}

$args = $arguments->except([0])->implode(',');
Expand Down
37 changes: 0 additions & 37 deletions tests/BladeMacroServiceProviderTest.php

This file was deleted.

4 changes: 2 additions & 2 deletions tests/MacroTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function test_show_macro(): void
{
Macro::$macros['testcase'] = 'hello';

$macro = Macro::show('testcase');
$macro = Macro::show('testcase ');

self::assertSame(
"<?php echo \JeroenG\BladeMacro\Macro::\$macros['testcase'](); ?>",
Expand All @@ -60,7 +60,7 @@ public function test_show_macro(): void

public function test_showing_undefined_macro_throws_exception(): void
{
$this->expectException(\Exception::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The `testcase` macro is not defined.');

self::assertEmpty(Macro::$macros);
Expand Down

0 comments on commit 49eaf44

Please sign in to comment.