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

AbstractAlipay   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 6 3
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