Passed
Push — master ( e4a200...c44a4f )
by Songda
03:06 queued 01:11
created

RefundShortcut::defaultPlugins()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 11
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Shortcut\Alipay;
6
7
use Yansongda\Pay\Contract\ShortcutInterface;
8
use Yansongda\Pay\Exception\Exception;
9
use Yansongda\Pay\Exception\InvalidParamsException;
10
use Yansongda\Pay\Plugin\Alipay\AddRadarPlugin;
11
use Yansongda\Pay\Plugin\Alipay\AddSignaturePlugin;
12
use Yansongda\Pay\Plugin\Alipay\FormatBizContentPlugin;
13
use Yansongda\Pay\Plugin\Alipay\Fund\Transfer\RefundPlugin as FundTransferRefundPlugin;
14
use Yansongda\Pay\Plugin\Alipay\Pay\Agreement\RefundPlugin as AgreementRefundPlugin;
15
use Yansongda\Pay\Plugin\Alipay\Pay\App\RefundPlugin as AppRefundPlugin;
16
use Yansongda\Pay\Plugin\Alipay\Pay\Authorization\RefundPlugin as AuthorizationRefundPlugin;
17
use Yansongda\Pay\Plugin\Alipay\Pay\Mini\RefundPlugin as MiniRefundPlugin;
18
use Yansongda\Pay\Plugin\Alipay\Pay\Pos\RefundPlugin as PosRefundPlugin;
19
use Yansongda\Pay\Plugin\Alipay\Pay\Scan\RefundPlugin as ScanRefundPlugin;
20
use Yansongda\Pay\Plugin\Alipay\Pay\Wap\RefundPlugin as WapRefundPlugin;
21
use Yansongda\Pay\Plugin\Alipay\Pay\Web\RefundPlugin as WebRefundPlugin;
22
use Yansongda\Pay\Plugin\Alipay\ResponsePlugin;
23
use Yansongda\Pay\Plugin\Alipay\StartPlugin;
24
use Yansongda\Pay\Plugin\Alipay\VerifySignaturePlugin;
25
use Yansongda\Pay\Plugin\ParserPlugin;
26
use Yansongda\Supports\Str;
27
28
class RefundShortcut implements ShortcutInterface
29
{
30
    /**
31
     * @throws InvalidParamsException
32
     */
33
    public function getPlugins(array $params): array
34
    {
35
        $method = Str::camel($params['_action'] ?? 'default').'Plugins';
36
37
        if (method_exists($this, $method)) {
38
            return $this->{$method}();
39
        }
40
41
        throw new InvalidParamsException(Exception::SHORTCUT_MULTI_ACTION_ERROR, "Refund action [{$method}] not supported");
42
    }
43
44
    protected function defaultPlugins(): array
45
    {
46
        return [
47
            StartPlugin::class,
48
            WebRefundPlugin::class,
49
            FormatBizContentPlugin::class,
50
            AddSignaturePlugin::class,
51
            AddRadarPlugin::class,
52
            VerifySignaturePlugin::class,
53
            ResponsePlugin::class,
54
            ParserPlugin::class,
55
        ];
56
    }
57
58
    protected function agreementPlugins(): array
59
    {
60
        return [
61
            StartPlugin::class,
62
            AgreementRefundPlugin::class,
63
            FormatBizContentPlugin::class,
64
            AddSignaturePlugin::class,
65
            AddRadarPlugin::class,
66
            VerifySignaturePlugin::class,
67
            ResponsePlugin::class,
68
            ParserPlugin::class,
69
        ];
70
    }
71
72
    protected function appPlugins(): array
73
    {
74
        return [
75
            StartPlugin::class,
76
            AppRefundPlugin::class,
77
            FormatBizContentPlugin::class,
78
            AddSignaturePlugin::class,
79
            AddRadarPlugin::class,
80
            VerifySignaturePlugin::class,
81
            ResponsePlugin::class,
82
            ParserPlugin::class,
83
        ];
84
    }
85
86
    protected function authorizationPlugins(): array
87
    {
88
        return [
89
            StartPlugin::class,
90
            AuthorizationRefundPlugin::class,
91
            FormatBizContentPlugin::class,
92
            AddSignaturePlugin::class,
93
            AddRadarPlugin::class,
94
            VerifySignaturePlugin::class,
95
            ResponsePlugin::class,
96
            ParserPlugin::class,
97
        ];
98
    }
99
100
    protected function miniPlugins(): array
101
    {
102
        return [
103
            StartPlugin::class,
104
            MiniRefundPlugin::class,
105
            FormatBizContentPlugin::class,
106
            AddSignaturePlugin::class,
107
            AddRadarPlugin::class,
108
            VerifySignaturePlugin::class,
109
            ResponsePlugin::class,
110
            ParserPlugin::class,
111
        ];
112
    }
113
114
    protected function posPlugins(): array
115
    {
116
        return [
117
            StartPlugin::class,
118
            PosRefundPlugin::class,
119
            FormatBizContentPlugin::class,
120
            AddSignaturePlugin::class,
121
            AddRadarPlugin::class,
122
            VerifySignaturePlugin::class,
123
            ResponsePlugin::class,
124
            ParserPlugin::class,
125
        ];
126
    }
127
128
    protected function scanPlugins(): array
129
    {
130
        return [
131
            StartPlugin::class,
132
            ScanRefundPlugin::class,
133
            FormatBizContentPlugin::class,
134
            AddSignaturePlugin::class,
135
            AddRadarPlugin::class,
136
            VerifySignaturePlugin::class,
137
            ResponsePlugin::class,
138
            ParserPlugin::class,
139
        ];
140
    }
141
142
    protected function wapPlugins(): array
143
    {
144
        return [
145
            StartPlugin::class,
146
            WapRefundPlugin::class,
147
            FormatBizContentPlugin::class,
148
            AddSignaturePlugin::class,
149
            AddRadarPlugin::class,
150
            VerifySignaturePlugin::class,
151
            ResponsePlugin::class,
152
            ParserPlugin::class,
153
        ];
154
    }
155
156
    protected function webPlugins(): array
157
    {
158
        return [
159
            StartPlugin::class,
160
            WebRefundPlugin::class,
161
            FormatBizContentPlugin::class,
162
            AddSignaturePlugin::class,
163
            AddRadarPlugin::class,
164
            VerifySignaturePlugin::class,
165
            ResponsePlugin::class,
166
            ParserPlugin::class,
167
        ];
168
    }
169
170
    protected function transferPlugins(): array
171
    {
172
        return [
173
            StartPlugin::class,
174
            FundTransferRefundPlugin::class,
175
            FormatBizContentPlugin::class,
176
            AddSignaturePlugin::class,
177
            AddRadarPlugin::class,
178
            VerifySignaturePlugin::class,
179
            ResponsePlugin::class,
180
            ParserPlugin::class,
181
        ];
182
    }
183
}
184