Passed
Push — master ( a6a7ae...bf6fd0 )
by i
03:53
created

AbstractAlipay::toEncoding()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 3
dl 0
loc 15
ccs 0
cts 7
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Nilnice\Payment\Alipay;
4
5
use Nilnice\Payment\Alipay\Traits\RequestTrait;
6
use Nilnice\Payment\Alipay\Traits\SecurityTrait;
7
use Nilnice\Payment\PaymentInterface;
8
9
abstract class AbstractAlipay implements PaymentInterface
10
{
11
    use SecurityTrait;
12
    use RequestTrait;
13
14
    /**
15
     * Check order arguments.
16
     *
17
     * @param array $order
18
     *
19
     * @return void
20
     * @throws \InvalidArgumentException
21
     */
22 3
    public static function check(array $order) : void
23
    {
24 3
        $required = ['out_trade_no', 'total_amount', 'subject'];
25 3
        foreach ($required as $key => $item) {
26 3
            if (! array_key_exists($item, $order)) {
27 3
                throw new \InvalidArgumentException("The {$item} field is required");
28
            }
29
        }
30 3
    }
31
}
32