VerifySignaturePlugin::assembly()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 18
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Wechat\V2;
6
7
use Closure;
8
use Yansongda\Artful\Contract\PluginInterface;
9
use Yansongda\Artful\Exception\ContainerException;
10
use Yansongda\Artful\Exception\InvalidConfigException;
11
use Yansongda\Artful\Exception\ServiceNotFoundException;
12
use Yansongda\Artful\Logger;
13
use Yansongda\Artful\Rocket;
14
use Yansongda\Pay\Exception\InvalidSignException;
15
16
use function Yansongda\Artful\should_do_http_request;
17
use function Yansongda\Pay\get_provider_config;
18
use function Yansongda\Pay\verify_wechat_sign_v2;
19
20
class VerifySignaturePlugin implements PluginInterface
21
{
22
    /**
23
     * @throws ContainerException
24
     * @throws InvalidConfigException
25
     * @throws ServiceNotFoundException
26
     * @throws InvalidSignException
27
     */
28
    public function assembly(Rocket $rocket, Closure $next): Rocket
29
    {
30
        /* @var Rocket $rocket */
31
        $rocket = $next($rocket);
32
33
        Logger::debug('[Wechat][V2][VerifySignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
34
35
        $config = get_provider_config('wechat', $rocket->getParams());
36
37
        if (!should_do_http_request($rocket->getDirection())) {
38
            return $rocket;
39
        }
40
41
        verify_wechat_sign_v2($config, $rocket->getDestination()?->all() ?? []);
0 ignored issues
show
Bug introduced by
The method all() does not exist on Psr\Http\Message\MessageInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        verify_wechat_sign_v2($config, $rocket->getDestination()?->/** @scrutinizer ignore-call */ all() ?? []);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
43
        Logger::info('[Wechat][V2][VerifySignaturePlugin] 插件装载完毕', ['rocket' => $rocket]);
44
45
        return $rocket;
46
    }
47
}
48