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

AbstractAlipay::getSignContent()   C

Complexity

Conditions 10
Paths 5

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 110

Importance

Changes 0
Metric Value
cc 10
eloc 14
nc 5
nop 2
dl 0
loc 24
ccs 0
cts 15
cp 0
crap 110
rs 5.2164
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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