代码初始化
This commit is contained in:
38
addons/epay/library/v3/Yansongda/Pay/Event.php
Normal file
38
addons/epay/library/v3/Yansongda/Pay/Event.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay;
|
||||
|
||||
use Yansongda\Pay\Contract\EventDispatcherInterface;
|
||||
use Yansongda\Pay\Exception\ContainerException;
|
||||
use Yansongda\Pay\Exception\InvalidConfigException;
|
||||
use Yansongda\Pay\Exception\ServiceNotFoundException;
|
||||
|
||||
/**
|
||||
* @method static Event\Event dispatch(object $event)
|
||||
*/
|
||||
class Event
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws ServiceNotFoundException
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public static function __callStatic(string $method, array $args): void
|
||||
{
|
||||
if (!Pay::hasContainer() || !Pay::has(EventDispatcherInterface::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = Pay::get(EventDispatcherInterface::class);
|
||||
|
||||
if ($class instanceof \Psr\EventDispatcher\EventDispatcherInterface) {
|
||||
$class->{$method}(...$args);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidConfigException(Exception\Exception::EVENT_CONFIG_ERROR);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user