chore: validate and autocomplete flasher configuration

This commit is contained in:
Younes ENNAJI
2024-10-19 02:02:53 +01:00
parent d0022aa0cb
commit 09f53b1b63
2 changed files with 70 additions and 2 deletions
+4 -2
View File
@@ -2,7 +2,9 @@
declare(strict_types=1);
return [
use Flasher\Prime\Configuration;
return Configuration::from([
// Default notification library (e.g., 'flasher', 'toastr', 'noty', 'notyf', 'sweetalert')
'default' => 'flasher',
@@ -50,4 +52,4 @@ return [
// 'message' => 'Entity saved successfully',
// ],
// ],
];
]);
+66
View File
@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
namespace Flasher\Prime;
/**
* @phpstan-type ConfigType array{
* default: string,
* main_script?: string,
* scripts?: string[],
* styles?: string[],
* inject_assets?: bool,
* translate?: bool,
* excluded_paths?: list<non-empty-string>,
* options?: array<string, mixed>,
* filter?: array<string, mixed>,
* flash_bag?: false|array<string, string[]>,
* presets?: array<string, array{
* type: string,
* title: string,
* message: string,
* options: array<string, mixed>,
* }>,
* plugins?: array<string, array{
* scripts?: string[],
* styles?: string[],
* options?: array<string, mixed>,
* }>,
* }
*/
final class Configuration
{
/**
* @param array{
* default: string,
* main_script?: string,
* scripts?: string[],
* styles?: string[],
* inject_assets?: bool,
* translate?: bool,
* excluded_paths?: list<non-empty-string>,
* options?: array<string, mixed>,
* filter?: array<string, mixed>,
* flash_bag?: false|array<string, string[]>,
* presets?: array<string, array{
* type: string,
* title: string,
* message: string,
* options: array<string, mixed>,
* }>,
* plugins?: array<string, array{
* scripts?: string[],
* styles?: string[],
* options?: array<string, mixed>,
* }>,
* } $config
* @phpstan-param ConfigType $config
*
* @return ConfigType
*/
public static function from(array $config): array
{
return $config;
}
}