Skip to content

Commit

Permalink
merge from v3
Browse files Browse the repository at this point in the history
  • Loading branch information
yansongda committed Jun 6, 2021
2 parents d08d153 + a434f12 commit 8f60e57
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/Functions.php
Expand Up @@ -10,11 +10,14 @@
use Yansongda\Supports\Config;
use Yansongda\Supports\Str;

if (!function_exists('should_http_request')) {
function should_http_request(Rocket $rocket): bool
if (!function_exists('should_do_http_request')) {
function should_do_http_request(Rocket $rocket): bool
{
return NoHttpRequestParser::class !== $rocket->getDirection() &&
!in_array(NoHttpRequestParser::class, class_parents($rocket->getDirection()));
$direction = $rocket->getDirection();

return is_null($direction) ||
(NoHttpRequestParser::class !== $direction &&
!in_array(NoHttpRequestParser::class, class_parents($direction)));
}
}

Expand Down
13 changes: 12 additions & 1 deletion src/Pay.php
Expand Up @@ -120,6 +120,8 @@ public static function config(array $config): Pay
* @author yansongda <me@yansongda.cn>
*
* @param mixed $value
*
* @throws \Yansongda\Pay\Exception\ContainerException
*/
public static function set(string $name, $value): void
{
Expand Down Expand Up @@ -148,6 +150,9 @@ public static function get(string $service)
}
}

/**
* @throws \Yansongda\Pay\Exception\ContainerException
*/
public static function has(string $service): bool
{
return Pay::getContainer()->has($service);
Expand All @@ -157,10 +162,16 @@ public static function has(string $service): bool
* getContainer.
*
* @author yansongda <me@yansongda.cn>
*
* @throws \Yansongda\Pay\Exception\ContainerException
*/
public static function getContainer(): Container
{
return self::$container;
if (self::$container) {
return self::$container;
}

throw new ContainerException('You should init/config PAY first', ContainerException::CONTAINER_NOT_FOUND);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Alipay/LaunchPlugin.php
Expand Up @@ -24,7 +24,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
/* @var Rocket $rocket */
$rocket = $next($rocket);

if (!should_http_request($rocket)) {
if (!should_do_http_request($rocket)) {
return $rocket;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/AbstractProvider.php
Expand Up @@ -51,7 +51,7 @@ public function pay(array $plugins, array $params)
*/
public function ignite(Rocket $rocket): Rocket
{
if (!should_http_request($rocket)) {
if (!should_do_http_request($rocket)) {
return $rocket;
}

Expand Down

0 comments on commit 8f60e57

Please sign in to comment.