diff --git a/config/alert.php b/config/alert.php index f22cf77e..506b88cf 100644 --- a/config/alert.php +++ b/config/alert.php @@ -27,80 +27,80 @@ 'themes' => [ 'classic' => [ 'components' => 'Digitlimit\Alert\View\Components\Themes\Classic', - 'types' => [ + 'types' => [ 'message' => [ - 'view' => 'alert-message', - 'alert' => Types\Message::class, + 'view' => 'alert-message', + 'alert' => Types\Message::class, 'component' => Themes\Classic\Message::class, ], 'field' => [ - 'view' => 'alert-field', - 'alert' => Types\Field::class, + 'view' => 'alert-field', + 'alert' => Types\Field::class, 'component' => Themes\Classic\Field::class, ], 'bag' => [ - 'view' => 'alert-field', - 'alert' => Types\FieldBag::class, + 'view' => 'alert-field', + 'alert' => Types\FieldBag::class, 'component' => Themes\Classic\Field::class, ], 'modal' => [ - 'view' => 'alert-modal', - 'alert' => Types\Modal::class, + 'view' => 'alert-modal', + 'alert' => Types\Modal::class, 'component' => Themes\Classic\Modal::class, ], 'notify' => [ - 'view' => 'alert-notify', - 'alert' => Types\Notify::class, + 'view' => 'alert-notify', + 'alert' => Types\Notify::class, 'component' => Themes\Classic\Notify::class, ], 'sticky' => [ - 'view' => 'alert-sticky', - 'alert' => Types\Sticky::class, + 'view' => 'alert-sticky', + 'alert' => Types\Sticky::class, 'component' => Themes\Classic\Sticky::class, ], ], ], 'bootstrap5' => [ 'components' => 'Digitlimit\Alert\View\Components\Themes\Bootstrap5', - 'types' => [ + 'types' => [ 'message' => [ - 'view' => 'alert-message', - 'alert' => Types\Message::class, + 'view' => 'alert-message', + 'alert' => Types\Message::class, 'component' => Themes\Bootstrap5\Message::class, ], 'field' => [ - 'view' => 'alert-field', - 'alert' => Types\Field::class, + 'view' => 'alert-field', + 'alert' => Types\Field::class, 'component' => Themes\Bootstrap5\Field::class, ], 'bag' => [ - 'view' => 'alert-field', - 'alert' => Types\FieldBag::class, + 'view' => 'alert-field', + 'alert' => Types\FieldBag::class, 'component' => Themes\Bootstrap5\Field::class, ], 'modal' => [ - 'view' => 'alert-modal', - 'alert' => Types\Modal::class, + 'view' => 'alert-modal', + 'alert' => Types\Modal::class, 'component' => Themes\Bootstrap5\Modal::class, ], 'notify' => [ - 'view' => 'alert-notify', - 'alert' => Types\Notify::class, + 'view' => 'alert-notify', + 'alert' => Types\Notify::class, 'component' => Themes\Bootstrap5\Notify::class, ], 'sticky' => [ - 'view' => 'alert-sticky', - 'alert' => Types\Sticky::class, + 'view' => 'alert-sticky', + 'alert' => Types\Sticky::class, 'component' => Themes\Bootstrap5\Sticky::class, ], ], diff --git a/src/Alert.php b/src/Alert.php index 7db6b3fc..89647eed 100644 --- a/src/Alert.php +++ b/src/Alert.php @@ -25,7 +25,8 @@ class Alert */ public function __construct( protected SessionInterface $session - ) {} + ) { + } /** * Fetch an alert based on the default tag. @@ -43,7 +44,7 @@ public function named( string $name, ?string $tag = null ): ?MessageInterface { - if (! Type::exists($type)) { + if (!Type::exists($type)) { throw new Exception("Invalid alert type '$type'. Check the alert config"); } @@ -61,7 +62,7 @@ public function tagged( string $type, string $tag ): ?MessageInterface { - if (! Type::exists($type)) { + if (!Type::exists($type)) { throw new Exception("Invalid alert type '$type'. Check the alert config"); } @@ -141,7 +142,7 @@ public function from( string $type, ...$args ): MessageInterface { - if (! Type::exists($type)) { + if (!Type::exists($type)) { throw new Exception("Invalid alert type '$type'. Check the alert config"); } diff --git a/src/Component/Button.php b/src/Component/Button.php index 3902c407..7b3ea6c2 100644 --- a/src/Component/Button.php +++ b/src/Component/Button.php @@ -13,7 +13,8 @@ public function __construct( public ?string $label = null, public ?string $link = null, public array $attributes = [] - ) {} + ) { + } /** * Set the button label. diff --git a/src/Helpers.php b/src/Helpers.php index 7f907c38..d85b3093 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -3,7 +3,7 @@ use Illuminate\Support\MessageBag; use Illuminate\Validation\Validator; -if (! function_exists('alert')) { +if (!function_exists('alert')) { function alert(string $message, ?string $title = null): mixed { $alert = app('alert') @@ -18,7 +18,7 @@ function alert(string $message, ?string $title = null): mixed } } -if (! function_exists('field')) { +if (!function_exists('field')) { function field(string $name, string $message, ?string $tag = null): mixed { $alert = app('alert')->field($name, $message); @@ -31,7 +31,7 @@ function field(string $name, string $message, ?string $tag = null): mixed } } -if (! function_exists('fieldBag')) { +if (!function_exists('fieldBag')) { function fieldBag(Validator|MessageBag $bag): mixed { return app('alert') @@ -39,7 +39,7 @@ function fieldBag(Validator|MessageBag $bag): mixed } } -if (! function_exists('modal')) { +if (!function_exists('modal')) { function modal(string $message, ?string $title = null): mixed { $alert = app('alert')->modal($message); @@ -52,7 +52,7 @@ function modal(string $message, ?string $title = null): mixed } } -if (! function_exists('notify')) { +if (!function_exists('notify')) { function notify(string $message, ?string $title = null): mixed { $alert = app('alert')->notify($message); @@ -65,7 +65,7 @@ function notify(string $message, ?string $title = null): mixed } } -if (! function_exists('sticky')) { +if (!function_exists('sticky')) { function sticky(string $message, ?string $title = null): mixed { $alert = app('alert')->sticky($message); @@ -78,7 +78,7 @@ function sticky(string $message, ?string $title = null): mixed } } -if (! function_exists('forgetSticky')) { +if (!function_exists('forgetSticky')) { function forgetSticky(?string $name = null): void { app('alert')->stickForget($name); diff --git a/src/Helpers/Type.php b/src/Helpers/Type.php index f3029018..692c87d3 100644 --- a/src/Helpers/Type.php +++ b/src/Helpers/Type.php @@ -54,7 +54,7 @@ public static function type(string $type): array */ public static function classname(string $type): string { - if (! self::exists($type)) { + if (!self::exists($type)) { throw new Exception("The alert type '$type' does not exist in config"); } diff --git a/src/Message/MessageFactory.php b/src/Message/MessageFactory.php index 7c62a784..60fd9179 100644 --- a/src/Message/MessageFactory.php +++ b/src/Message/MessageFactory.php @@ -15,7 +15,7 @@ public static function make(SessionInterface $session, string $type, ...$args): { $class = Type::classname($type); - if (! class_exists($class)) { + if (!class_exists($class)) { throw new Exception("Alert type '$class' class not found "); } diff --git a/src/Types/FieldBag.php b/src/Types/FieldBag.php index afa2bf43..23652817 100644 --- a/src/Types/FieldBag.php +++ b/src/Types/FieldBag.php @@ -32,7 +32,7 @@ public function __construct( } elseif (is_a($bag, MessageBag::class)) { $this->messages($bag); } else { - $this->messages = new MessageBag; + $this->messages = new MessageBag(); } } diff --git a/src/Types/Modal.php b/src/Types/Modal.php index 7a1e2646..169bd006 100644 --- a/src/Types/Modal.php +++ b/src/Types/Modal.php @@ -51,8 +51,8 @@ public function __construct( public ?string $message ) { $this->id($this->key().'-'.Helper::randomString()); - $this->action = new Button; - $this->cancel = new Button; + $this->action = new Button(); + $this->cancel = new Button(); } /** diff --git a/src/Types/Sticky.php b/src/Types/Sticky.php index 4b1dcab6..e2babc44 100644 --- a/src/Types/Sticky.php +++ b/src/Types/Sticky.php @@ -27,7 +27,7 @@ public function __construct( public ?string $message ) { $this->id($this->key().'-'.Helper::randomString()); - $this->action = new Button; + $this->action = new Button(); } /** diff --git a/src/View/Components/Themes/Bootstrap5/Modal.php b/src/View/Components/Themes/Bootstrap5/Modal.php index a64fd2e3..3e48380b 100644 --- a/src/View/Components/Themes/Bootstrap5/Modal.php +++ b/src/View/Components/Themes/Bootstrap5/Modal.php @@ -23,7 +23,7 @@ class Modal extends Component * Default action button attributes. */ public array $actionAttributes = [ - 'type' => 'button', + 'type' => 'button', 'class' => 'btn btn-primary', ]; @@ -31,8 +31,8 @@ class Modal extends Component * Default cancel button attributes. */ public array $cancelAttributes = [ - 'type' => 'button', - 'class' => 'btn btn-secondary', + 'type' => 'button', + 'class' => 'btn btn-secondary', 'data-bs-dismiss' => 'modal', ]; diff --git a/src/View/Components/Themes/Bootstrap5/Sticky.php b/src/View/Components/Themes/Bootstrap5/Sticky.php index 47ad3bc2..9153c449 100644 --- a/src/View/Components/Themes/Bootstrap5/Sticky.php +++ b/src/View/Components/Themes/Bootstrap5/Sticky.php @@ -23,7 +23,7 @@ class Sticky extends Component * Default action button. */ public array $actionAttributes = [ - 'type' => 'button', + 'type' => 'button', 'class' => 'btn btn-sm btn-primary float-end', ]; diff --git a/src/View/Components/Themes/Classic/Modal.php b/src/View/Components/Themes/Classic/Modal.php index ed6577b6..97a139bb 100644 --- a/src/View/Components/Themes/Classic/Modal.php +++ b/src/View/Components/Themes/Classic/Modal.php @@ -23,7 +23,7 @@ class Modal extends Component * Default action button attributes. */ public array $actionAttributes = [ - 'type' => 'button', + 'type' => 'button', 'class' => 'btn btn-primary', ]; @@ -31,8 +31,8 @@ class Modal extends Component * Default cancel button attributes. */ public array $cancelAttributes = [ - 'type' => 'button', - 'class' => 'btn btn-secondary', + 'type' => 'button', + 'class' => 'btn btn-secondary', 'data-bs-dismiss' => 'modal', ]; diff --git a/src/View/Components/Themes/Classic/Sticky.php b/src/View/Components/Themes/Classic/Sticky.php index 6e001544..979203cf 100644 --- a/src/View/Components/Themes/Classic/Sticky.php +++ b/src/View/Components/Themes/Classic/Sticky.php @@ -23,7 +23,7 @@ class Sticky extends Component * Default action button. */ public array $actionAttributes = [ - 'type' => 'button', + 'type' => 'button', 'class' => 'btn btn-sm btn-primary float-end', ]; diff --git a/tests/Feature/Components/FieldBagTest.php b/tests/Feature/Components/FieldBagTest.php index d42231ac..01e0814d 100644 --- a/tests/Feature/Components/FieldBagTest.php +++ b/tests/Feature/Components/FieldBagTest.php @@ -7,7 +7,7 @@ ['firstname' => '', 'lastname' => ''], [ 'firstname' => 'required', - 'lastname' => 'required', + 'lastname' => 'required', ] ); diff --git a/tests/Feature/Components/FieldTest.php b/tests/Feature/Components/FieldTest.php index ba344a54..952fd751 100644 --- a/tests/Feature/Components/FieldTest.php +++ b/tests/Feature/Components/FieldTest.php @@ -12,7 +12,6 @@ $view ->assertSee('class="form-text text-success"', false) ->assertSee('Username is available'); - })->group('view-component', 'view-component-field-default'); it('can render a tagged field view component', function () { @@ -26,7 +25,6 @@ $view ->assertSee('class="form-text text-warning"', false) ->assertSee('Please select a country'); - })->group('view-component', 'view-component-field-tagged'); it('can render a named field view component', function () { @@ -45,5 +43,4 @@ ->assertSee('class="form-text text-success"', false) ->assertSee('Good, you chose a valid country') ->assertDontSee('Good, you chose a valid state'); - })->group('view-component', 'view-component-field-named-tagged'); diff --git a/tests/Feature/Helpers/FieldTest.php b/tests/Feature/Helpers/FieldTest.php index 899c496e..21289d0d 100644 --- a/tests/Feature/Helpers/FieldTest.php +++ b/tests/Feature/Helpers/FieldTest.php @@ -15,5 +15,4 @@ ->toBeInstanceOf(Field::class) ->and($default->message) ->toEqual('Invalid firstname'); - })->group('types', 'types-field'); diff --git a/tests/Feature/Helpers/MessageTest.php b/tests/Feature/Helpers/MessageTest.php index e20589f7..202769f9 100644 --- a/tests/Feature/Helpers/MessageTest.php +++ b/tests/Feature/Helpers/MessageTest.php @@ -15,5 +15,4 @@ ->toBeInstanceOf(Message::class) ->and($default->message) ->toEqual('Thank you!'); - })->group('types', 'types-default', 'types-message'); diff --git a/tests/Feature/Helpers/ModalTest.php b/tests/Feature/Helpers/ModalTest.php index 82a72a24..ed066367 100644 --- a/tests/Feature/Helpers/ModalTest.php +++ b/tests/Feature/Helpers/ModalTest.php @@ -15,5 +15,4 @@ ->toBeInstanceOf(Modal::class) ->and($default->message) ->toEqual('Thank you!'); - })->group('types', 'types-modal', 'types-modal'); diff --git a/tests/Feature/Helpers/NotifyTest.php b/tests/Feature/Helpers/NotifyTest.php index 01ce4a41..874923cb 100644 --- a/tests/Feature/Helpers/NotifyTest.php +++ b/tests/Feature/Helpers/NotifyTest.php @@ -17,5 +17,4 @@ ->toEqual('Thank you!') ->and($default->key()) ->toEqual('notify'); - })->group('types', 'types-notify', 'types-notify'); diff --git a/tests/Feature/Helpers/StickyTest.php b/tests/Feature/Helpers/StickyTest.php index 19514e79..9eb4e66d 100644 --- a/tests/Feature/Helpers/StickyTest.php +++ b/tests/Feature/Helpers/StickyTest.php @@ -15,5 +15,4 @@ ->toBeInstanceOf(Sticky::class) ->and($default->message) ->toEqual('Thank you!'); - })->group('types', 'types-sticky', 'types-sticky-message'); diff --git a/tests/Feature/Types/FieldTest.php b/tests/Feature/Types/FieldTest.php index 606eb4b8..656c2a3a 100644 --- a/tests/Feature/Types/FieldTest.php +++ b/tests/Feature/Types/FieldTest.php @@ -15,5 +15,4 @@ ->toBeInstanceOf(Field::class) ->and($default->message) ->toEqual('Invalid firstname'); - })->group('types', 'types-field', 'types-field'); diff --git a/tests/Feature/Types/MessageTest.php b/tests/Feature/Types/MessageTest.php index 1dd4318d..ee429eb7 100644 --- a/tests/Feature/Types/MessageTest.php +++ b/tests/Feature/Types/MessageTest.php @@ -15,5 +15,4 @@ ->toBeInstanceOf(Message::class) ->and($default->message) ->toEqual('Thank you!'); - })->group('types', 'types-default', 'types-message'); diff --git a/tests/Feature/Types/ModalTest.php b/tests/Feature/Types/ModalTest.php index da2ddab7..82a8d5c9 100644 --- a/tests/Feature/Types/ModalTest.php +++ b/tests/Feature/Types/ModalTest.php @@ -15,5 +15,4 @@ ->toBeInstanceOf(Modal::class) ->and($default->message) ->toEqual('Thank you!'); - })->group('types', 'types-modal', 'types-modal'); diff --git a/tests/Feature/Types/NotifyTest.php b/tests/Feature/Types/NotifyTest.php index 621c2ae4..2a6bee1b 100644 --- a/tests/Feature/Types/NotifyTest.php +++ b/tests/Feature/Types/NotifyTest.php @@ -16,7 +16,6 @@ ->toEqual('Thank you!') ->and($default->key()) ->toEqual('notify'); - })->group('types', 'types-notify', 'types-notify'); it('can create a notify alert position', function () { diff --git a/tests/Feature/Types/StickyTest.php b/tests/Feature/Types/StickyTest.php index 21251663..0ffc45e3 100644 --- a/tests/Feature/Types/StickyTest.php +++ b/tests/Feature/Types/StickyTest.php @@ -16,7 +16,6 @@ ->toBeInstanceOf(Sticky::class) ->and($default->message) ->toEqual('Thank you!'); - })->group('types', 'types-sticky', 'types-sticky-message'); it('can create a sticky alert title', function () { @@ -29,7 +28,6 @@ ->toEqual('Order') ->and($default->message) ->toEqual('Thank for ordering pizza!'); - })->group('types', 'types-sticky', 'types-sticky-title'); it('can create a sticky alert button', function () { @@ -40,5 +38,4 @@ expect($default->action) ->toBeInstanceOf(Button::class); - })->group('types', 'types-sticky', 'types-sticky-button'); diff --git a/tests/TestCase.php b/tests/TestCase.php index f532c7b1..9ae3ca2c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -20,7 +20,8 @@ protected function getPackageProviders($app) /** * Override application aliases. * - * @param \Illuminate\Foundation\Application $app + * @param \Illuminate\Foundation\Application $app + * * @return array> */ protected function getPackageAliases($app) diff --git a/tests/Unit/Helpers/AttributeTest.php b/tests/Unit/Helpers/AttributeTest.php index ff099075..be43bc79 100644 --- a/tests/Unit/Helpers/AttributeTest.php +++ b/tests/Unit/Helpers/AttributeTest.php @@ -4,7 +4,7 @@ it('can generate html element attribute from an array', function () { $attributesString = Attribute::toString([ - 'id' => 'alert-id', + 'id' => 'alert-id', 'class' => 'alert alert-success', ]); diff --git a/tests/Unit/Helpers/ThemeTest.php b/tests/Unit/Helpers/ThemeTest.php index 0bdf622d..63244bb4 100644 --- a/tests/Unit/Helpers/ThemeTest.php +++ b/tests/Unit/Helpers/ThemeTest.php @@ -9,7 +9,6 @@ expect($theme) ->toEqual('bootstrap5') ->and(Theme::name())->toEqual('bootstrap5'); - })->group('theme', 'helpers', 'theme-name'); it('can get all themes', function () { @@ -20,7 +19,6 @@ ->not()->toBeEmpty() ->toBeArray() ->toEqual(Theme::all()); - })->group('theme', 'helpers', 'theme-all'); it('can get the correct theme based on config', function () { @@ -41,5 +39,4 @@ ->toBeArray() ->not()->toBeEmpty() ->toEqual(config('alert.themes.classic')); - })->group('theme', 'helpers', 'theme-theme');