add using method as alias for create factory method

This commit is contained in:
Khoubza Younes
2021-10-23 10:10:49 +01:00
parent 55c08b02d9
commit 93ede1b03a
8 changed files with 42 additions and 3 deletions
+4
View File
@@ -5,3 +5,7 @@ namespace PHPSTORM_META;
override(\Flasher\Prime\FlasherInterface::create(), map([
'cli' => \Flasher\Cli\Prime\CliNotificationFactory::class
]));
override(\Flasher\Prime\FlasherInterface::using(), map([
'cli' => \Flasher\Cli\Prime\CliNotificationFactory::class
]));
+4
View File
@@ -14,3 +14,7 @@ expectedArguments(\Flasher\Noty\Prime\NotyBuilder::queue(), 0, 'global');
override(\Flasher\Prime\FlasherInterface::create(), map([
'noty' => \Flasher\Noty\Prime\NotyFactory::class
]));
override(\Flasher\Prime\FlasherInterface::using(), map([
'noty' => \Flasher\Noty\Prime\NotyFactory::class
]));
+5 -1
View File
@@ -7,5 +7,9 @@ expectedArguments(\Flasher\Notyf\Prime\NotyfBuilder::position(), 0, 'x', 'y');
expectedArguments(\Flasher\Notyf\Prime\NotyfBuilder::position(), 1, 'top', 'right', 'bottom', 'left', 'center');
override(\Flasher\Prime\FlasherInterface::create(), map([
'notyf' => \Flasher\Notyf\Prime\NotyfFactory::class
'notyf' => \Flasher\Notyf\Prime\NotyfFactory::class,
]));
override(\Flasher\Prime\FlasherInterface::using(), map([
'notyf' => \Flasher\Notyf\Prime\NotyfFactory::class,
]));
+4
View File
@@ -17,3 +17,7 @@ expectedArguments(\Flasher\Pnotify\Prime\PnotifyBuilder::history(), 0, 'history
override(\Flasher\Prime\FlasherInterface::create(), map([
'pnotify' => \Flasher\Pnotify\Prime\PnotifyFactory::class
]));
override(\Flasher\Prime\FlasherInterface::using(), map([
'pnotify' => \Flasher\Pnotify\Prime\PnotifyFactory::class
]));
+5
View File
@@ -52,6 +52,11 @@ final class Flasher implements FlasherInterface
return $this->factories[$alias];
}
public function using($alias)
{
return $this->create($alias);
}
public function addFactory($alias, NotificationFactoryInterface $factory)
{
$this->factories[$alias] = $factory;
+11
View File
@@ -21,6 +21,17 @@ interface FlasherInterface
*/
public function create($alias = null);
/**
* Get a driver instance.
*
* @param string|null $alias
*
* @return NotificationFactoryInterface
*
* @throws \InvalidArgumentException
*/
public function using($alias);
/**
* Register a custom driver creator.
*
+4
View File
@@ -14,3 +14,7 @@ expectedArguments(\Flasher\SweetAlert\Prime\SweetAlertBuilder::customClass(), 0,
override(\Flasher\Prime\FlasherInterface::create(), map([
'sweet_alert' => \Flasher\SweetAlert\Prime\SweetAlertFactory::class
]));
override(\Flasher\Prime\FlasherInterface::using(), map([
'sweet_alert' => \Flasher\SweetAlert\Prime\SweetAlertFactory::class
]));
+5 -2
View File
@@ -8,6 +8,9 @@ expectedArguments(\Flasher\Toastr\Prime\ToastrBuilder::showEasing(), 0, 'swing',
expectedArguments(\Flasher\Toastr\Prime\ToastrBuilder::hideEasing(), 0, 'swing', 'linear');
expectedArguments(\Flasher\Toastr\Prime\ToastrBuilder::positionClass(), 0, 'toast-top-right', 'toast-top-center', 'toast-bottom-center', 'toast-top-full-width', 'toast-bottom-full-width', 'toast-top-left', 'toast-bottom-right', 'toast-bottom-left');
override(\Flasher\Prime\FlasherInterface::create(), map([
$mapping = map([
'toastr' => \Flasher\Toastr\Prime\ToastrFactory::class
]));
]);
override(\Flasher\Prime\FlasherInterface::create(), map($mapping));
override(\Flasher\Prime\FlasherInterface::using(), map($mapping));