diff --git a/config/alert.php b/config/alert.php index 5274ba6c..03a89901 100644 --- a/config/alert.php +++ b/config/alert.php @@ -10,7 +10,7 @@ | Here you may register your custom alert types | */ - + 'types' => [ 'alert-normal' => [ 'alert' => \Digitlimit\Alert\Types\Normal::class, @@ -19,22 +19,22 @@ 'alert-field' => [ 'alert' => \Digitlimit\Alert\Types\Field::class, - 'component' => \Digitlimit\Alert\View\Components\Field::class + 'component' => \Digitlimit\Alert\View\Components\Field::class, ], 'alert-modal' => [ 'alert' => \Digitlimit\Alert\Types\Modal::class, - 'component' => \Digitlimit\Alert\View\Components\Modal::class + 'component' => \Digitlimit\Alert\View\Components\Modal::class, ], 'alert-notify' => [ 'alert' => \Digitlimit\Alert\Types\Notify::class, - 'component' => \Digitlimit\Alert\View\Components\Notify::class + 'component' => \Digitlimit\Alert\View\Components\Notify::class, ], 'alert-sticky' => [ 'alert' => \Digitlimit\Alert\Types\Sticky::class, - 'component' => \Digitlimit\Alert\View\Components\Sticky::class - ] - ] + 'component' => \Digitlimit\Alert\View\Components\Sticky::class, + ], + ], ]; diff --git a/src/Alert.php b/src/Alert.php index d7333185..2275a155 100644 --- a/src/Alert.php +++ b/src/Alert.php @@ -2,12 +2,12 @@ namespace Digitlimit\Alert; -use Digitlimit\Alert\Message\MessageInterface; -use Digitlimit\Alert\Message\MessageFactory; use Digitlimit\Alert\Helpers\SessionKey; use Digitlimit\Alert\Helpers\Type; -use Illuminate\Validation\Validator; +use Digitlimit\Alert\Message\MessageFactory; +use Digitlimit\Alert\Message\MessageInterface; use Exception; +use Illuminate\Validation\Validator; class Alert { @@ -18,34 +18,35 @@ class Alert /** * Create a new alert instance. + * * @return void */ public function __construct( protected SessionInterface $session - ){} + ) { + } /** - * Fetch an alert based on the default tag + * Fetch an alert based on the default tag. */ - public function default(string $type) : MessageInterface|null + public function default(string $type): MessageInterface|null { return self::tagged($type, self::DEFAULT_TAG); } /** - * Fetch an alert based on the type and named + * Fetch an alert based on the type and named. */ public function named( string $type, string $name, string $tag = null - ) : MessageInterface|null { - - if(!Type::exists($type)) { + ): MessageInterface|null { + if (!Type::exists($type)) { throw new Exception("Invalid alert type '$type'. Check the alert config"); } - $tag = ($tag ?? self::DEFAULT_TAG) . '.' . $name; + $tag = ($tag ?? self::DEFAULT_TAG).'.'.$name; return $this->session->get( SessionKey::key($type, $tag) @@ -53,14 +54,13 @@ public function named( } /** - * Fetch an alert based on the tag name + * Fetch an alert based on the tag name. */ public function tagged( - string $type, + string $type, string $tag - ) : MessageInterface|null { - - if(!Type::exists($type)) { + ): MessageInterface|null { + if (!Type::exists($type)) { throw new Exception("Invalid alert type '$type'. Check the alert config"); } @@ -68,7 +68,7 @@ public function tagged( SessionKey::key($type, $tag) ); - if(is_array($tagged)) { + if (is_array($tagged)) { return null; } @@ -76,70 +76,72 @@ public function tagged( } /** - * Fetch the normal alert + * Fetch the normal alert. */ - public function normal(string $message=null) : MessageInterface + public function normal(string $message = null): MessageInterface { return MessageFactory::make($this->session, 'normal', $message); } /** - * Fetch the field alert + * Fetch the field alert. */ public function field( - string $message=null, - ?Validator $validator=null - ) : MessageInterface { + string $message = null, + ?Validator $validator = null + ): MessageInterface { return MessageFactory::make( - $this->session, 'field', $message, $validator + $this->session, + 'field', + $message, + $validator ); } /** - * Fetch the modal alert + * Fetch the modal alert. */ - public function modal(string $message=null) : MessageInterface + public function modal(string $message = null): MessageInterface { return MessageFactory::make($this->session, 'modal', $message); } /** - * Fetch the notify alert + * Fetch the notify alert. */ - public function notify(string $message=null) : MessageInterface + public function notify(string $message = null): MessageInterface { return MessageFactory::make($this->session, 'notify', $message); } /** - * Fetch the sticky alert + * Fetch the sticky alert. */ - public function sticky(string $message=null) : MessageInterface + public function sticky(string $message = null): MessageInterface { return MessageFactory::make($this->session, 'sticky', $message); } /** - * Fetch the default alert type, which is the normal alert + * Fetch the default alert type, which is the normal alert. */ - public function message(string $message) : MessageInterface + public function message(string $message): MessageInterface { return $this->normal($message); } /** - * Fetch an alert from the given alert type + * Fetch an alert from the given alert type. */ public function from( - string $type, - string $message=null, + string $type, + string $message = null, ...$args - ) : MessageInterface { - - if(!Type::exists($type)) { + ): MessageInterface { + if (!Type::exists($type)) { throw new Exception("Invalid alert type '$type'. Check the alert config"); } return MessageFactory::make($this->session, $type, $message, ...$args); } -} \ No newline at end of file +} diff --git a/src/AlertServiceProvider.php b/src/AlertServiceProvider.php index 886f9457..266094ae 100644 --- a/src/AlertServiceProvider.php +++ b/src/AlertServiceProvider.php @@ -1,10 +1,9 @@ app->bind(SessionInterface::class, Session::class); - $this->app->bind(ConfigInterface::class, Config::class); + $this->app->bind(ConfigInterface::class, Config::class); $this->app->singleton('alert', function ($app) { return $app->make(Alert::class); }); $this->mergeConfigFrom( - __DIR__.'/../config/alert.php', 'alert' + __DIR__.'/../config/alert.php', + 'alert' ); } /** * Get the services provided by the provider. */ - public function provides() : array + public function provides(): array { return ['alert']; } @@ -54,23 +54,22 @@ protected function bootForConsole(): void __DIR__.'/../resources/views' => base_path('resources/views/vendor/digitlimit/alert'), ], 'alert.views'); - $this->publishes([ __DIR__.'/../config/alert.php' => config_path('alert.php'), ], 'alert.config'); } /** - * Register alert components + * Register alert components. */ - protected function registerComponents() : void + protected function registerComponents(): void { Blade::componentNamespace('Digitlimit\\Alert\View\\Components', 'alert'); $types = config('alert.types'); - foreach($types as $name => $type) { - Blade::component($name, $type['component']); + foreach ($types as $name => $type) { + Blade::component($name, $type['component']); } } -} \ No newline at end of file +} diff --git a/src/Component/Button.php b/src/Component/Button.php index 63b3a437..7b3ea6c2 100644 --- a/src/Component/Button.php +++ b/src/Component/Button.php @@ -4,37 +4,39 @@ class Button { - /** - * Create a new button instance. - * @return void - */ - public function __construct( - public ?string $label = null, - public ?string $link = null, - public array $attributes = [] - ){} + /** + * Create a new button instance. + * + * @return void + */ + public function __construct( + public ?string $label = null, + public ?string $link = null, + public array $attributes = [] + ) { + } - /** - * Set the button label - */ - public function label(string $label) : void - { - $this->label = $label; - } + /** + * Set the button label. + */ + public function label(string $label): void + { + $this->label = $label; + } - /** - * Set the button link - */ - public function link(string $link) : void - { - $this->link = $link; - } + /** + * Set the button link. + */ + public function link(string $link): void + { + $this->link = $link; + } - /** - * Set the button attributes - */ - public function attributes(array $attributes) : void - { - $this->attributes = $attributes; - } -} \ No newline at end of file + /** + * Set the button attributes. + */ + public function attributes(array $attributes): void + { + $this->attributes = $attributes; + } +} diff --git a/src/Config.php b/src/Config.php index e7ac8690..3a40a23e 100644 --- a/src/Config.php +++ b/src/Config.php @@ -7,7 +7,7 @@ class Config implements ConfigInterface { /** - * The config + * The config. */ private Repository $config; @@ -17,9 +17,9 @@ public function __construct(Repository $config) } /** - * Fetch value from the config based on the given key + * Fetch value from the config based on the given key. */ - public function get(string $key, mixed $default=null) : mixed + public function get(string $key, mixed $default = null): mixed { return $this->config->get($key, $default); } diff --git a/src/ConfigInterface.php b/src/ConfigInterface.php index 005be1ce..472628a4 100644 --- a/src/ConfigInterface.php +++ b/src/ConfigInterface.php @@ -5,7 +5,7 @@ interface ConfigInterface { /** - * Fetch value from the config based on the given key + * Fetch value from the config based on the given key. */ - public function get(string $key, string $default=null) : mixed; -} \ No newline at end of file + public function get(string $key, string $default = null): mixed; +} diff --git a/src/Helpers.php b/src/Helpers.php index 16829657..84b57926 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -1,15 +1,14 @@ message($message) ->title($title) @@ -18,4 +17,4 @@ function alert(string $message=null, string $title=null) : mixed return $alert; } -} \ No newline at end of file +} diff --git a/src/Helpers/Attribute.php b/src/Helpers/Attribute.php index c36ee9d6..29d85d0c 100644 --- a/src/Helpers/Attribute.php +++ b/src/Helpers/Attribute.php @@ -5,19 +5,17 @@ class Attribute { /** - * Convert attributes array to HTML string attributes + * Convert attributes array to HTML string attributes. */ - public static function toString(array $attributes) : string + public static function toString(array $attributes): string { - $newAttributes = array_map(function($key) use ($attributes) - { - $key = htmlspecialchars($key); + $newAttributes = array_map(function ($key) use ($attributes) { + $key = htmlspecialchars($key); $value = htmlspecialchars($attributes[$key]) ?? ''; return "$key=\"$value\""; - }, array_keys($attributes)); return join(' ', $newAttributes); } -} \ No newline at end of file +} diff --git a/src/Helpers/Helper.php b/src/Helpers/Helper.php index 9aaf4516..5ac28a3e 100644 --- a/src/Helpers/Helper.php +++ b/src/Helpers/Helper.php @@ -3,12 +3,12 @@ namespace Digitlimit\Alert\Helpers; class Helper -{ +{ /** - * Generate a random string + * Generate a random string. */ - public static function randomString(int $length=10) : string + public static function randomString(int $length = 10): string { return substr(md5(mt_rand()), 0, $length); } -} \ No newline at end of file +} diff --git a/src/Helpers/SessionKey.php b/src/Helpers/SessionKey.php index 11cfd801..ab66384d 100644 --- a/src/Helpers/SessionKey.php +++ b/src/Helpers/SessionKey.php @@ -5,17 +5,17 @@ class SessionKey { /** - * Default alert store key + * Default alert store key. */ const MAIN_KEY = 'digitlimit.alert'; /** - * Get session key for a given type and tag + * Get session key for a given type and tag. */ - public static function key(string $type, string $tag) : string + public static function key(string $type, string $tag): string { - return self::MAIN_KEY - . '.' . $type - . '.' . $tag; + return self::MAIN_KEY + .'.'.$type + .'.'.$tag; } -} \ No newline at end of file +} diff --git a/src/Helpers/Type.php b/src/Helpers/Type.php index 01d2b9ac..8340012c 100644 --- a/src/Helpers/Type.php +++ b/src/Helpers/Type.php @@ -2,62 +2,64 @@ namespace Digitlimit\Alert\Helpers; -use Exception; use Digitlimit\Alert\ConfigInterface; +use Exception; class Type -{ +{ /** - * Alert type prefix + * Alert type prefix. */ const PREFIX = 'alert-'; /** - * Fetch alert types from the config file + * Fetch alert types from the config file. */ - public static function types() : array + public static function types(): array { $config = app(ConfigInterface::class); - + return $config ->get('alert.types'); } /** - * Get the prefixed type for an alert type + * Get the prefixed type for an alert type. */ - public static function prefixed(string $type) : string + public static function prefixed(string $type): string { - return self::PREFIX . $type; + return self::PREFIX.$type; } /** - * Check if an alert type exists + * Check if an alert type exists. */ - public static function exists(string $type) : bool + public static function exists(string $type): bool { $types = self::types(); + return isset($types[$type]) || isset($types[self::prefixed($type)]); } /** - * Get an alert type + * Get an alert type. */ - public static function type(string $type) : array + public static function type(string $type): array { $types = self::types(); + return $types[$type] ?? $types[self::prefixed($type)]; } /** - * Get alert class name + * Get alert class name. */ - public static function clasname(string $type) : string + public static function clasname(string $type): string { - if(!self::exists($type)) { + if (!self::exists($type)) { throw new Exception("The alert type '$type' does not exist in config"); } - + return self::type($type)['alert']; } -} \ No newline at end of file +} diff --git a/src/Message/AbstractMessage.php b/src/Message/AbstractMessage.php index a211b207..ae2b7e1f 100644 --- a/src/Message/AbstractMessage.php +++ b/src/Message/AbstractMessage.php @@ -2,116 +2,121 @@ namespace Digitlimit\Alert\Message; +use Digitlimit\Alert\Alert; +use Digitlimit\Alert\Helpers\SessionKey; use Digitlimit\Alert\Session; use Digitlimit\Alert\Traits\Levelable; -use Digitlimit\Alert\Helpers\SessionKey; -use Digitlimit\Alert\Alert; abstract class AbstractMessage implements MessageInterface { /** - * Import the alert levels from trait + * Import the alert levels from trait. */ use Levelable; /** - * Alert store + * Alert store. */ protected Session $session; /** - * Alert unique ID + * Alert unique ID. */ public string|int $id; /** - * Alert message + * Alert message. */ public ?string $message = null; /** - * Alert title + * Alert title. */ public ?string $title = null; /** - * Alert level + * Alert level. */ public ?string $level = null; /** - * Alert tag + * Alert tag. */ protected string $tag = Alert::DEFAULT_TAG; /** - * Abstract alert key method should return alert key + * Abstract alert key method should return alert key. */ - abstract public function key() : string; + abstract public function key(): string; /** - * Set alert ID + * Set alert ID. */ - public function id(string|int $id) : self + public function id(string|int $id): self { $this->id = $id; + return $this; } /** - * Set alert level + * Set alert level. */ - public function level(string $level) : self + public function level(string $level): self { $this->level = $level; + return $this; } /** - * Set alert message + * Set alert message. */ - public function message(string $message) : self + public function message(string $message): self { $this->message = $message; + return $this; } /** - * Set the alert title + * Set the alert title. */ - public function title(string $title) : self + public function title(string $title): self { $this->title = $title; + return $this; } /** - * Set the alert tag + * Set the alert tag. */ - public function tag(string $tag) : self + public function tag(string $tag): self { $this->tag = $tag; + return $this; } /** - * Fetch the alert tag + * Fetch the alert tag. */ - public function getTag() : string + public function getTag(): string { return $this->tag; } /** * Flash alert to store. - * Its a temporal store that is deleted once pulled/fetched + * Its a temporal store that is deleted once pulled/fetched. */ - public function flash(string $message=null, string $level=null) : void + public function flash(string $message = null, string $level = null): void { $this->message = $message ?? $this->message; - $this->level = $level ?? $this->level; + $this->level = $level ?? $this->level; - $sessionKey = SessionKey::key($this->key(), $this->getTag()); + $sessionKey = SessionKey::key($this->key(), $this->getTag()); $this->session->flash($sessionKey, $this); } -} \ No newline at end of file +} diff --git a/src/Message/MessageFactory.php b/src/Message/MessageFactory.php index 7731ccd3..17123115 100644 --- a/src/Message/MessageFactory.php +++ b/src/Message/MessageFactory.php @@ -2,23 +2,23 @@ namespace Digitlimit\Alert\Message; -use Exception; use Digitlimit\Alert\Helpers\Type; use Digitlimit\Alert\Session; +use Exception; class MessageFactory -{ +{ /** - * Make a new alert instance + * Make a new alert instance. */ - public static function make(Session $session, string $type, ...$args) : MessageInterface + public static function make(Session $session, string $type, ...$args): MessageInterface { $class = Type::clasname($type); - if(!class_exists($class)) { + if (!class_exists($class)) { throw new Exception("Alert type '$class' class not found "); } return new $class($session, ...$args); } -} \ No newline at end of file +} diff --git a/src/Message/MessageInterface.php b/src/Message/MessageInterface.php index 45b071a3..3938cb03 100644 --- a/src/Message/MessageInterface.php +++ b/src/Message/MessageInterface.php @@ -5,32 +5,32 @@ interface MessageInterface { /** - * Set the alert ID + * Set the alert ID. */ - public function id(string|int $id) : self; - + public function id(string|int $id): self; + /** - * Set the alert message + * Set the alert message. */ - public function message(string $message) : self; + public function message(string $message): self; /** - * Set the alert title + * Set the alert title. */ - public function title(string $title) : self; + public function title(string $title): self; /** - * Set the alert level + * Set the alert level. */ - public function level(string $level) : self; + public function level(string $level): self; /** - * Set the alert tag + * Set the alert tag. */ - public function tag(string $tag) : self; + public function tag(string $tag): self; /** - * Flash the alert to store + * Flash the alert to store. */ - public function flash(string $message=null, string $level=null) : void; -} \ No newline at end of file + public function flash(string $message = null, string $level = null): void; +} diff --git a/src/Session.php b/src/Session.php index 7be8511d..40c63fe0 100644 --- a/src/Session.php +++ b/src/Session.php @@ -7,7 +7,7 @@ class Session implements SessionInterface { /** - * The store + * The store. */ private Store $store; @@ -17,17 +17,17 @@ public function __construct(Store $store) } /** - * Flash alert to store + * Flash alert to store. */ - public function flash(string $key, mixed $value) : void + public function flash(string $key, mixed $value): void { $this->store->flash($key, $value); } /** - * Fetch alert from the store + * Fetch alert from the store. */ - public function get(string $key, mixed $default=null) : mixed + public function get(string $key, mixed $default = null): mixed { return $this->store->get($key, $default); } diff --git a/src/SessionInterface.php b/src/SessionInterface.php index 098d5657..2c84cb06 100644 --- a/src/SessionInterface.php +++ b/src/SessionInterface.php @@ -5,12 +5,12 @@ interface SessionInterface { /** - * Flash alert to store + * Flash alert to store. */ - public function flash(string $name, mixed $value) : void; + public function flash(string $name, mixed $value): void; /** - * Fetch alert from the store + * Fetch alert from the store. */ - public function get(string $key, mixed $default=null) : mixed; + public function get(string $key, mixed $default = null): mixed; } diff --git a/src/Traits/Levelable.php b/src/Traits/Levelable.php index 0d1707ab..005ef542 100644 --- a/src/Traits/Levelable.php +++ b/src/Traits/Levelable.php @@ -4,75 +4,83 @@ trait Levelable { - /** - * Primary alert level - */ - public function primary() : self - { - $this->level = 'primary'; - return $this; - } - - /** - * Secondary alert level - */ - public function secondary() : self - { - $this->level = 'secondary'; - return $this; - } - - /** - * Success alert level - */ - public function success() : self - { - $this->level = 'success'; - return $this; - } - - /** - * Info alert level - */ - public function info() : self - { - $this->level = 'info'; - return $this; - } - - /** - * Error alert level - */ - public function error() : self - { - $this->level = 'danger'; - return $this; - } - - /** - * Warning alert level - */ - public function warning() : self - { - $this->level = 'warning'; - return $this; - } - - /** - * Light alert level - */ - public function light() : self - { - $this->level = 'light'; - return $this; - } - - /** - * Dark alert level - */ - public function dark() : self - { - $this->level = 'dark'; - return $this; - } -} \ No newline at end of file + /** + * Primary alert level. + */ + public function primary(): self + { + $this->level = 'primary'; + + return $this; + } + + /** + * Secondary alert level. + */ + public function secondary(): self + { + $this->level = 'secondary'; + + return $this; + } + + /** + * Success alert level. + */ + public function success(): self + { + $this->level = 'success'; + + return $this; + } + + /** + * Info alert level. + */ + public function info(): self + { + $this->level = 'info'; + + return $this; + } + + /** + * Error alert level. + */ + public function error(): self + { + $this->level = 'danger'; + + return $this; + } + + /** + * Warning alert level. + */ + public function warning(): self + { + $this->level = 'warning'; + + return $this; + } + + /** + * Light alert level. + */ + public function light(): self + { + $this->level = 'light'; + + return $this; + } + + /** + * Dark alert level. + */ + public function dark(): self + { + $this->level = 'dark'; + + return $this; + } +} diff --git a/src/Types/Field.php b/src/Types/Field.php index fea43cb0..fc0ee84e 100644 --- a/src/Types/Field.php +++ b/src/Types/Field.php @@ -2,41 +2,42 @@ namespace Digitlimit\Alert\Types; +use Digitlimit\Alert\Helpers\Helper; +use Digitlimit\Alert\Helpers\SessionKey; use Digitlimit\Alert\Message\AbstractMessage; use Digitlimit\Alert\Message\MessageInterface; -use Illuminate\Validation\Validator; -use Illuminate\Support\MessageBag; use Digitlimit\Alert\Session; -use Digitlimit\Alert\Helpers\SessionKey; -use Digitlimit\Alert\Helpers\Helper; use Exception; +use Illuminate\Support\MessageBag; +use Illuminate\Validation\Validator; class Field extends AbstractMessage implements MessageInterface { /** - * Field name + * Field name. */ public ?string $name = null; /** - * Field message back + * Field message back. */ public MessageBag $messages; /** * Create a new field alert instance. + * * @return void */ public function __construct( - protected Session $session, + protected Session $session, public ?string $message - ){ + ) { $this->id(Helper::randomString()); $this->messages = new MessageBag(); } /** - * Message store key for the field alert + * Message store key for the field alert. */ public function key(): string { @@ -44,68 +45,71 @@ public function key(): string } /** - * Set field name + * Set field name. */ - public function name(string $name) : self + public function name(string $name): self { $this->name = $name; + return $this; } /** - * Set messages + * Set messages. */ - public function messages(MessageBag $messages) : self - { + public function messages(MessageBag $messages): self + { $this->messages = $messages; + return $this; } /** - * Set errors + * Set errors. */ - public function errors(Validator $validator) : self + public function errors(Validator $validator): self { $this->messages = $validator->errors(); + return $this; } /** - * Fetch message for a given field name + * Fetch message for a given field name. */ - public function messageFor(string $name) : string + public function messageFor(string $name): string { return $this->messages->first($name); } /** - * Get field store tag + * Get field store tag. */ - public function getTag() : string + public function getTag(): string { - if($this->name) { + if ($this->name) { //e.g default.firstname - return $this->tag . '.' . $this->name; + return $this->tag.'.'.$this->name; } return $this->tag; } /** - * Flash field instance to store + * Flash field instance to store. */ - public function flash(string $message=null, string $level=null) : void + public function flash(string $message = null, string $level = null): void { $this->message = $message ?? $this->message; - $this->level = $level ?? $this->level; + $this->level = $level ?? $this->level; - if($this->messages->isEmpty() && empty($this->name)) { + if ($this->messages->isEmpty() && empty($this->name)) { throw new Exception( - "Messages or field name is required. Hint: messages(\$validator) or name(\$name)" + 'Messages or field name is required. Hint: messages($validator) or name($name)' ); } - $sessionKey = SessionKey::key($this->key(), $this->getTag()); + $sessionKey = SessionKey::key($this->key(), $this->getTag()); $this->session->flash($sessionKey, $this); } -} \ No newline at end of file +} diff --git a/src/Types/Modal.php b/src/Types/Modal.php index 0590d46f..f4757a0b 100644 --- a/src/Types/Modal.php +++ b/src/Types/Modal.php @@ -2,60 +2,61 @@ namespace Digitlimit\Alert\Types; +use Digitlimit\Alert\Component\Button; +use Digitlimit\Alert\Helpers\Helper; use Digitlimit\Alert\Message\AbstractMessage; use Digitlimit\Alert\Message\MessageInterface; use Digitlimit\Alert\Session; -use Digitlimit\Alert\Component\Button; use Illuminate\View\View; -use Digitlimit\Alert\Helpers\Helper; class Modal extends AbstractMessage implements MessageInterface { /** - * An instance of action button + * An instance of action button. */ public Button $action; /** - * An instance of cancel button + * An instance of cancel button. */ public Button $cancel; /** - * The modal size + * The modal size. */ public ?string $size = null; /** - * The scrollable class for modal if given + * The scrollable class for modal if given. */ public ?string $scrollable = null; /** - * The position of the modal on the screen if given + * The position of the modal on the screen if given. */ public ?string $position = null; /** - * The view HTML string if given + * The view HTML string if given. */ public ?string $view = null; /** * Create a new modal alert instance. + * * @return void */ public function __construct( - protected Session $session, + protected Session $session, public ?string $message - ){ + ) { $this->id(Helper::randomString()); $this->action = new Button(); $this->cancel = new Button(); } - + /** - * Message store key for the modal alert + * Message store key for the modal alert. */ public function key(): string { @@ -63,93 +64,103 @@ public function key(): string } /** - * Set the action button + * Set the action button. */ - public function action(string $label, string $link=null, array $attributes=[]) : self + public function action(string $label, string $link = null, array $attributes = []): self { $this->action = new Button($label, $link, $attributes); + return $this; } /** - * Set the cancel button + * Set the cancel button. */ - public function cancel(string $label, string $link=null, array $attributes=[]) : self + public function cancel(string $label, string $link = null, array $attributes = []): self { $this->cancel = new Button($label, $link, $attributes); + return $this; } /** - * Set modal to scrollable + * Set modal to scrollable. */ public function scrollable( - string $class='modal-dialog-scrollable' - ) : self { + string $class = 'modal-dialog-scrollable' + ): self { $this->scrollable = $class; + return $this; } /** - * Set modal size to small + * Set modal size to small. */ - public function small(string $class='modal-sm') : self + public function small(string $class = 'modal-sm'): self { $this->size = $class; + return $this; } /** - * Set modal size to large + * Set modal size to large. */ - public function large(string $class='modal-lg') : self + public function large(string $class = 'modal-lg'): self { $this->size = $class; + return $this; } /** - * Set modal size to extra-large + * Set modal size to extra-large. */ - public function extraLarge(string $class='modal-xl') : self + public function extraLarge(string $class = 'modal-xl'): self { $this->size = $class; + return $this; } /** - * Set modal size to fullscreen + * Set modal size to fullscreen. */ - public function fullscreen(string $class='modal-fullscreen') : self + public function fullscreen(string $class = 'modal-fullscreen'): self { $this->size = $class; + return $this; } /** - * Set modal position to center + * Set modal position to center. */ - public function centered(string $class='modal-dialog-centered') : self + public function centered(string $class = 'modal-dialog-centered'): self { $this->position = $class; + return $this; } /** - * Set a view for the modal + * Set a view for the modal. */ - public function view(View $view) : self + public function view(View $view): self { $this->view = $view->render(); + return $this; } /** - * Set HTML string for the modal + * Set HTML string for the modal. */ - public function html(string $html) : self + public function html(string $html): self { $this->view = $html; + return $this; } -} \ No newline at end of file +} diff --git a/src/Types/Normal.php b/src/Types/Normal.php index 87dbb0ec..1be09a54 100644 --- a/src/Types/Normal.php +++ b/src/Types/Normal.php @@ -2,29 +2,30 @@ namespace Digitlimit\Alert\Types; +use Digitlimit\Alert\Helpers\Helper; use Digitlimit\Alert\Message\AbstractMessage; use Digitlimit\Alert\Message\MessageInterface; use Digitlimit\Alert\Session; -use Digitlimit\Alert\Helpers\Helper; class Normal extends AbstractMessage implements MessageInterface { /** * Create a new nomal alert instance. + * * @return void */ public function __construct( - protected Session $session, + protected Session $session, public ?string $message - ){ + ) { $this->id(Helper::randomString()); } /** - * Message store key for the normal alert + * Message store key for the normal alert. */ public function key(): string { return 'normal'; } -} \ No newline at end of file +} diff --git a/src/Types/Notify.php b/src/Types/Notify.php index 59e4084a..1b61a23f 100644 --- a/src/Types/Notify.php +++ b/src/Types/Notify.php @@ -2,32 +2,33 @@ namespace Digitlimit\Alert\Types; +use Digitlimit\Alert\Helpers\Helper; use Digitlimit\Alert\Message\AbstractMessage; use Digitlimit\Alert\Message\MessageInterface; use Digitlimit\Alert\Session; -use Digitlimit\Alert\Helpers\Helper; class Notify extends AbstractMessage implements MessageInterface { /** - * The position of the notify + * The position of the notify. */ public ?string $position = null; /** * Create a new notify alert instance. + * * @return void */ public function __construct( - protected Session $session, + protected Session $session, public ?string $message ) { $this->id(Helper::randomString()); $this->bottomRight(); } - + /** - * Message store key for the notify alert + * Message store key for the notify alert. */ public function key(): string { @@ -35,65 +36,72 @@ public function key(): string } /** - * Position notify on center of the screen + * Position notify on center of the screen. */ - public function centered(string $class='top-50 start-50 translate-middle') : self + public function centered(string $class = 'top-50 start-50 translate-middle'): self { $this->position = $class; + return $this; } - + /** - * Position notify on the center of the screen + * Position notify on the center of the screen. */ - public function topLeft(string $class='top-0 start-0') : self + public function topLeft(string $class = 'top-0 start-0'): self { $this->position = $class; + return $this; } /** - * Position notify on the top right of the screen + * Position notify on the top right of the screen. */ - public function topRight(string $class='top-0 end-0') : self + public function topRight(string $class = 'top-0 end-0'): self { $this->position = $class; + return $this; } /** - * Position notify on the top center of the screen + * Position notify on the top center of the screen. */ - public function topCenter(string $class='top-0 start-50 translate-middle-x') : self + public function topCenter(string $class = 'top-0 start-50 translate-middle-x'): self { $this->position = $class; + return $this; } /** - * Position notify on the bottom left of the screen + * Position notify on the bottom left of the screen. */ - public function bottomLeft(string $class='bottom-0 start-0') : self + public function bottomLeft(string $class = 'bottom-0 start-0'): self { $this->position = $class; + return $this; } /** - * Position notify on the bottom right of the screen + * Position notify on the bottom right of the screen. */ - public function bottomRight(string $class='bottom-0 end-0') : self + public function bottomRight(string $class = 'bottom-0 end-0'): self { $this->position = $class; + return $this; } /** - * Position notify on the bottom center of the screen + * Position notify on the bottom center of the screen. */ - public function bottomCenter(string $class='bottom-0 start-50 translate-middle-x') : self + public function bottomCenter(string $class = 'bottom-0 start-50 translate-middle-x'): self { $this->position = $class; + return $this; } -} \ No newline at end of file +} diff --git a/src/Types/Sticky.php b/src/Types/Sticky.php index 28546c10..78cfbbbd 100644 --- a/src/Types/Sticky.php +++ b/src/Types/Sticky.php @@ -2,25 +2,26 @@ namespace Digitlimit\Alert\Types; +use Digitlimit\Alert\Component\Button; +use Digitlimit\Alert\Helpers\Helper; use Digitlimit\Alert\Message\AbstractMessage; use Digitlimit\Alert\Message\MessageInterface; -use Digitlimit\Alert\Session; -use Digitlimit\Alert\Component\Button; -use Digitlimit\Alert\Helpers\Helper; +use Digitlimit\Alert\Session; class Sticky extends AbstractMessage implements MessageInterface { /** - * An instance of action button + * An instance of action button. */ public Button $action; - + /** * Create a new sticky alert instance. + * * @return void */ public function __construct( - protected Session $session, + protected Session $session, public ?string $message ) { $this->id(Helper::randomString()); @@ -28,7 +29,7 @@ public function __construct( } /** - * Message store key for the sticky alert + * Message store key for the sticky alert. */ public function key(): string { @@ -36,11 +37,12 @@ public function key(): string } /** - * Set the action button + * Set the action button. */ - public function action(string $label, string $link=null, array $attributes=[]) : self + public function action(string $label, string $link = null, array $attributes = []): self { $this->action = new Button($label, $link, $attributes); + return $this; } -} \ No newline at end of file +} diff --git a/src/View/Components/Field.php b/src/View/Components/Field.php index 7769a3c8..e8b8c43d 100644 --- a/src/View/Components/Field.php +++ b/src/View/Components/Field.php @@ -3,19 +3,19 @@ namespace Digitlimit\Alert\View\Components; use Closure; +use Digitlimit\Alert\Alert; use Illuminate\Contracts\View\View; use Illuminate\View\Component; -use Digitlimit\Alert\Alert; class Field extends Component { /** - * Set the default tag + * Set the default tag. */ public string $defaultTag = Alert::DEFAULT_TAG; /** - * Alert instance + * Alert instance. */ public Alert $alert; diff --git a/src/View/Components/Modal.php b/src/View/Components/Modal.php index 8aa22e83..c7bb8222 100644 --- a/src/View/Components/Modal.php +++ b/src/View/Components/Modal.php @@ -3,39 +3,38 @@ namespace Digitlimit\Alert\View\Components; use Closure; -use Illuminate\Contracts\View\View; -use Illuminate\View\Component; use Digitlimit\Alert\Alert; -use Illuminate\Support\Str; use Digitlimit\Alert\Helpers\Attribute; +use Illuminate\Contracts\View\View; +use Illuminate\View\Component; class Modal extends Component { /** - * Set the default tag + * Set the default tag. */ public string $defaultTag = Alert::DEFAULT_TAG; /** - * Alert instance + * Alert instance. */ public Alert $alert; /** - * Default action button attributes + * Default action button attributes. */ public array $actionAttributes = [ - 'type' => 'button', - 'class' => 'btn btn-primary' + 'type' => 'button', + 'class' => 'btn btn-primary', ]; /** - * Default cancel button attributes + * Default cancel button attributes. */ public array $cancelAttributes = [ - 'type' => 'button', + 'type' => 'button', 'class' => 'btn btn-secondary', - 'data-bs-dismiss' => 'modal' + 'data-bs-dismiss' => 'modal', ]; /** @@ -55,12 +54,12 @@ public function render(): View|Closure|string } /** - * Merge and convert array attributes to HTML string attributes + * Merge and convert array attributes to HTML string attributes. */ - public function actionAttributes(array $attributes) : string + public function actionAttributes(array $attributes): string { $newAttributes = array_merge( - $this->actionAttributes, + $this->actionAttributes, $attributes ); @@ -68,12 +67,12 @@ public function actionAttributes(array $attributes) : string } /** - * Merge and convert array attributes to HTML string attributes + * Merge and convert array attributes to HTML string attributes. */ - public function cancelAttributes(array $attributes) : string + public function cancelAttributes(array $attributes): string { $newAttributes = array_merge( - $this->cancelAttributes, + $this->cancelAttributes, $attributes ); diff --git a/src/View/Components/Normal.php b/src/View/Components/Normal.php index 47794c71..3baffde5 100644 --- a/src/View/Components/Normal.php +++ b/src/View/Components/Normal.php @@ -3,19 +3,19 @@ namespace Digitlimit\Alert\View\Components; use Closure; +use Digitlimit\Alert\Alert; use Illuminate\Contracts\View\View; use Illuminate\View\Component; -use Digitlimit\Alert\Alert; class Normal extends Component { /** - * Set the default tag + * Set the default tag. */ public string $defaultTag = Alert::DEFAULT_TAG; /** - * Alert instance + * Alert instance. */ public Alert $alert; @@ -34,4 +34,4 @@ public function render(): View|Closure|string { return view('alert::components.normal'); } -} \ No newline at end of file +} diff --git a/src/View/Components/Notify.php b/src/View/Components/Notify.php index 905f36f6..c552ae48 100644 --- a/src/View/Components/Notify.php +++ b/src/View/Components/Notify.php @@ -3,19 +3,19 @@ namespace Digitlimit\Alert\View\Components; use Closure; +use Digitlimit\Alert\Alert; use Illuminate\Contracts\View\View; use Illuminate\View\Component; -use Digitlimit\Alert\Alert; class Notify extends Component { /** - * Set the default tag + * Set the default tag. */ public string $defaultTag = Alert::DEFAULT_TAG; /** - * Alert instance + * Alert instance. */ public Alert $alert; diff --git a/src/View/Components/Sticky.php b/src/View/Components/Sticky.php index 4b4a2540..b1349f79 100644 --- a/src/View/Components/Sticky.php +++ b/src/View/Components/Sticky.php @@ -3,29 +3,29 @@ namespace Digitlimit\Alert\View\Components; use Closure; -use Illuminate\Contracts\View\View; -use Illuminate\View\Component; use Digitlimit\Alert\Alert; use Digitlimit\Alert\Helpers\Attribute; +use Illuminate\Contracts\View\View; +use Illuminate\View\Component; class Sticky extends Component { /** - * Set the default tag + * Set the default tag. */ public string $defaultTag = Alert::DEFAULT_TAG; /** - * Alert instance + * Alert instance. */ public Alert $alert; /** - * Default action button + * Default action button. */ public array $actionAttributes = [ - 'type' => 'button', - 'class' => 'btn btn-sm btn-primary float-end' + 'type' => 'button', + 'class' => 'btn btn-sm btn-primary float-end', ]; /** @@ -45,12 +45,12 @@ public function render(): View|Closure|string } /** - * Merge and convert array attributes to HTML string attributes + * Merge and convert array attributes to HTML string attributes. */ - public function actionAttributes(array $attributes) : string + public function actionAttributes(array $attributes): string { $newAttributes = array_merge( - $this->actionAttributes, + $this->actionAttributes, $attributes ); diff --git a/tests/Feature/Component/ButtonTest.php b/tests/Feature/Component/ButtonTest.php index 4e493671..a543ea10 100644 --- a/tests/Feature/Component/ButtonTest.php +++ b/tests/Feature/Component/ButtonTest.php @@ -2,20 +2,18 @@ use Digitlimit\Alert\Component\Button; -it('can create button component', function () -{ - $button = new Button('Submit', '/about', ['class' => 'btn-sm']); +it('can create button component', function () { + $button = new Button('Submit', '/about', ['class' => 'btn-sm']); - expect($button->label)->toEqual('Submit'); - expect($button->link)->toEqual('/about'); - expect($button->attributes)->toEqual(['class' => 'btn-sm']); + expect($button->label)->toEqual('Submit'); + expect($button->link)->toEqual('/about'); + expect($button->attributes)->toEqual(['class' => 'btn-sm']); - $button->label('Register'); - $button->link('/register'); - $button->attributes(['id' => 'register']); + $button->label('Register'); + $button->link('/register'); + $button->attributes(['id' => 'register']); - expect($button->label)->toEqual('Register'); - expect($button->link)->toEqual('/register'); - expect($button->attributes)->toEqual(['id' => 'register']); - -})->name('component', 'component-button'); \ No newline at end of file + expect($button->label)->toEqual('Register'); + expect($button->link)->toEqual('/register'); + expect($button->attributes)->toEqual(['id' => 'register']); +})->name('component', 'component-button'); diff --git a/tests/Feature/Components/FieldTest.php b/tests/Feature/Components/FieldTest.php index fd95c5d0..1cfa7e81 100644 --- a/tests/Feature/Components/FieldTest.php +++ b/tests/Feature/Components/FieldTest.php @@ -2,8 +2,7 @@ use Digitlimit\Alert\Facades\Alert; -it('can render a default field view component', function () -{ +it('can render a default field view component', function () { Alert::field('Username is available') ->success() ->name('username') @@ -15,11 +14,9 @@ $view ->assertSee('class="form-text text-success"', false) ->assertSee('Username is available'); - })->name('view-component', 'view-component-field-default'); -it('can render a tagged field view component', function () -{ +it('can render a tagged field view component', function () { Alert::field('Please select a country') ->tag('contact') ->name('country') @@ -32,11 +29,9 @@ $view ->assertSee('class="form-text text-warning"', false) ->assertSee('Please select a country'); - })->name('view-component', 'view-component-field-tagged'); -it('can render a named field view component', function () -{ +it('can render a named field view component', function () { Alert::field('Good, you chose a valid country') ->tag('contact') ->name('country') @@ -56,16 +51,14 @@ ->assertSee('class="form-text text-success"', false) ->assertSee('Good, you chose a valid country') ->assertDontSee('Good, you chose a valid state'); - })->name('view-component', 'view-component-field-tagged'); -it('can render validation errors for the field view component', function () -{ +it('can render validation errors for the field view component', function () { $validator = validator( - ['firstname' => '', 'lastname' => ''], + ['firstname' => '', 'lastname' => ''], [ - 'firstname' => 'required', - 'lastname' => 'required' + 'firstname' => 'required', + 'lastname' => 'required', ] ); @@ -84,5 +77,4 @@ ->blade('') ->assertSee('class="form-text text-danger"', false) ->assertSee('The lastname field is required'); - })->name('view-component', 'view-component-field-tagged'); diff --git a/tests/Feature/Components/ModalTest.php b/tests/Feature/Components/ModalTest.php index daa290e2..4629c878 100644 --- a/tests/Feature/Components/ModalTest.php +++ b/tests/Feature/Components/ModalTest.php @@ -1,10 +1,8 @@ flash(); @@ -12,11 +10,9 @@ ->blade('') ->assertSee('class="modal"', false) ->assertSee('Than you for joining us'); - })->name('view-component', 'view-component-modal-default'); -it('can render a default modal with buttons and title', function () -{ +it('can render a default modal with buttons and title', function () { Alert::modal('Your message has been recieved, you will hear from us soon') ->action('Yes') ->cancel('Cancel') @@ -34,11 +30,9 @@ ->assertSee('Cancel') ->assertSee('Please login') ->assertSee('Your message has been recieved, you will hear from us soon'); - })->name('view-component', 'view-component-modal-buttons-title'); -it('can render a default modal a the right position', function () -{ +it('can render a default modal a the right position', function () { Alert::modal() ->centered('centered') ->flash(); @@ -48,11 +42,9 @@ $view ->assertSee('class="modal-dialog centered "', false); - })->name('view-component', 'view-component-modal-position'); -it('can render a default modal a the right size', function () -{ +it('can render a default modal a the right size', function () { Alert::modal() ->small() ->flash(); @@ -68,7 +60,7 @@ $this ->blade('') ->assertSee('class="modal-dialog modal-lg "', false); - + Alert::modal() ->extraLarge() ->flash(); @@ -84,5 +76,4 @@ $this ->blade('') ->assertSee('class="modal-dialog modal-fullscreen "', false); - -})->name('view-component', 'view-component-modal-size'); \ No newline at end of file +})->name('view-component', 'view-component-modal-size'); diff --git a/tests/Feature/Components/NormalTest.php b/tests/Feature/Components/NormalTest.php index d3acffc3..be884498 100644 --- a/tests/Feature/Components/NormalTest.php +++ b/tests/Feature/Components/NormalTest.php @@ -2,8 +2,7 @@ use Digitlimit\Alert\Facades\Alert; -it('can render a default normal alert', function () -{ +it('can render a default normal alert', function () { Alert::normal('Thank you for joining us') ->flash(); @@ -11,5 +10,4 @@ ->blade('') ->assertSee('class="alert alert-dismissible alert-"', false) ->assertSee('Thank you for joining us'); - -})->name('view-component', 'view-component-normal-default'); \ No newline at end of file +})->name('view-component', 'view-component-normal-default'); diff --git a/tests/Feature/Components/Sticky.php b/tests/Feature/Components/Sticky.php index 641eb17c..f67b7f12 100644 --- a/tests/Feature/Components/Sticky.php +++ b/tests/Feature/Components/Sticky.php @@ -2,8 +2,7 @@ use Digitlimit\Alert\Facades\Alert; -it('can render a default normal alert', function () -{ +it('can render a default normal alert', function () { Alert::sticky('Thank you for joining us') ->flash(); @@ -11,5 +10,4 @@ ->blade('') ->assertSee('class="alert alert-"', false) ->assertSee('Thank you for joining us'); - -})->name('view-component', 'view-component-sticky-default'); \ No newline at end of file +})->name('view-component', 'view-component-sticky-default'); diff --git a/tests/Feature/Traits/LevelableTest.php b/tests/Feature/Traits/LevelableTest.php index b34c03c5..dec49323 100644 --- a/tests/Feature/Traits/LevelableTest.php +++ b/tests/Feature/Traits/LevelableTest.php @@ -2,8 +2,7 @@ use Digitlimit\Alert\Facades\Alert; -it('can sets the correct levels', function () -{ +it('can sets the correct levels', function () { $alert = Alert::message('Thank you!')->primary(); expect($alert->level)->toEqual('primary'); @@ -27,5 +26,4 @@ $alert = Alert::message('Thank you!')->dark(); expect($alert->level)->toEqual('dark'); - -})->name('traits', 'traits-levelable'); \ No newline at end of file +})->name('traits', 'traits-levelable'); diff --git a/tests/Feature/Types/FieldTest.php b/tests/Feature/Types/FieldTest.php index 69ace94f..8eea10b0 100644 --- a/tests/Feature/Types/FieldTest.php +++ b/tests/Feature/Types/FieldTest.php @@ -1,11 +1,10 @@ name('firstname') ->flash(); @@ -15,5 +14,4 @@ expect($default)->toBeInstanceOf(MessageInterface::class); expect($default)->toBeInstanceOf(Field::class); expect($default->message)->toEqual('Invalid firstname'); - })->name('types', 'types-field', 'types-field'); diff --git a/tests/Feature/Types/ModalTest.php b/tests/Feature/Types/ModalTest.php index 27a3322a..249809da 100644 --- a/tests/Feature/Types/ModalTest.php +++ b/tests/Feature/Types/ModalTest.php @@ -1,11 +1,10 @@ flash(); $default = Alert::default('modal'); @@ -13,5 +12,4 @@ expect($default)->toBeInstanceOf(MessageInterface::class); expect($default)->toBeInstanceOf(Modal::class); expect($default->message)->toEqual('Thank you!'); - })->name('types', 'types-modal', 'types-modal'); diff --git a/tests/Feature/Types/NormalTest.php b/tests/Feature/Types/NormalTest.php index 6307e33c..d4cd807c 100644 --- a/tests/Feature/Types/NormalTest.php +++ b/tests/Feature/Types/NormalTest.php @@ -1,11 +1,10 @@ flash(); $default = Alert::default('normal'); @@ -13,5 +12,4 @@ expect($default)->toBeInstanceOf(MessageInterface::class); expect($default)->toBeInstanceOf(Normal::class); expect($default->message)->toEqual('Thank you!'); - })->name('types', 'types-default', 'types-normal'); diff --git a/tests/Feature/Types/NotifyTest.php b/tests/Feature/Types/NotifyTest.php index a243c847..66e658bc 100644 --- a/tests/Feature/Types/NotifyTest.php +++ b/tests/Feature/Types/NotifyTest.php @@ -1,11 +1,10 @@ flash(); $default = Alert::default('notify'); @@ -13,5 +12,4 @@ expect($default)->toBeInstanceOf(MessageInterface::class); expect($default)->toBeInstanceOf(Notify::class); expect($default->message)->toEqual('Thank you!'); - })->name('types', 'types-notify', 'types-notify'); diff --git a/tests/Feature/Types/StickyTest.php b/tests/Feature/Types/StickyTest.php index a3896edf..0e6b452a 100644 --- a/tests/Feature/Types/StickyTest.php +++ b/tests/Feature/Types/StickyTest.php @@ -1,11 +1,10 @@ flash(); $default = Alert::default('sticky'); @@ -13,5 +12,4 @@ expect($default)->toBeInstanceOf(MessageInterface::class); expect($default)->toBeInstanceOf(Sticky::class); expect($default->message)->toEqual('Thank you!'); - })->name('types', 'types-sticky', 'types-sticky'); diff --git a/tests/Pest.php b/tests/Pest.php index 13f5c7ae..baff53e7 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -39,4 +39,4 @@ | project that you don't want to repeat in every file. Here you can also expose helpers as | global functions to help you to reduce the number of lines of code in your test files. | -*/ \ No newline at end of file +*/ diff --git a/tests/TestCase.php b/tests/TestCase.php index e039ac60..9ae3ca2c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,9 +2,9 @@ namespace Digitlimit\Alert\Tests; -use Orchestra\Testbench\TestCase as BaseTestCase; use Digitlimit\Alert\AlertServiceProvider; use Illuminate\Foundation\Testing\Concerns\InteractsWithViews; +use Orchestra\Testbench\TestCase as BaseTestCase; class TestCase extends BaseTestCase { @@ -20,24 +20,24 @@ protected function getPackageProviders($app) /** * Override application aliases. * - * @param \Illuminate\Foundation\Application $app + * @param \Illuminate\Foundation\Application $app * * @return array> */ protected function getPackageAliases($app) { return [ - + ]; } - + protected function getEnvironmentSetUp($app) { // perform environment setup } - public function packagePath(string $path='') + public function packagePath(string $path = '') { - return __DIR__ . "/../" . $path; + return __DIR__.'/../'.$path; } -} \ No newline at end of file +} diff --git a/tests/Unit/Helpers/AttributeTest.php b/tests/Unit/Helpers/AttributeTest.php index 0b2d30dc..be43bc79 100644 --- a/tests/Unit/Helpers/AttributeTest.php +++ b/tests/Unit/Helpers/AttributeTest.php @@ -2,14 +2,12 @@ use Digitlimit\Alert\Helpers\Attribute; -it('can generate html element attribute from an array', function () -{ +it('can generate html element attribute from an array', function () { $attributesString = Attribute::toString([ 'id' => 'alert-id', - 'class' => 'alert alert-success' + 'class' => 'alert alert-success', ]); expect($attributesString) ->toEqual('id="alert-id" class="alert alert-success"'); - -})->name('helpers', 'helpers-to-string'); \ No newline at end of file +})->name('helpers', 'helpers-to-string'); diff --git a/tests/Unit/Helpers/SessionKeyTest.php b/tests/Unit/Helpers/SessionKeyTest.php index 6ca84fa5..38740bf1 100644 --- a/tests/Unit/Helpers/SessionKeyTest.php +++ b/tests/Unit/Helpers/SessionKeyTest.php @@ -2,11 +2,9 @@ use Digitlimit\Alert\Helpers\SessionKey; -it('can generate a session key from tag name and alert type', function () -{ +it('can generate a session key from tag name and alert type', function () { $key = SessionKey::key('notify', 'contact-form-1'); expect($key) - ->toEqual(SessionKey::MAIN_KEY . ".notify.contact-form-1"); - -})->name('helpers', 'helpers-session-key'); \ No newline at end of file + ->toEqual(SessionKey::MAIN_KEY.'.notify.contact-form-1'); +})->name('helpers', 'helpers-session-key');