Completed
Push — master ( 721c87...eab9b9 )
by wannanbigpig
02:40
created

Alipay   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 37
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 10 2
A __callStatic() 0 3 1
1
<?php
2
/*
3
 * This file is part of the wannanbigpig/alipay.
4
 *
5
 * (c) wannanbigpig <[email protected]>
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace EasyAlipay;
12
13
use EasyAlipay\Kernel\Exceptions\ApplicationException;
14
use WannanBigPig\Supports\Str;
15
16
/**
17
 * Class Alipay
18
 *
19
 * @method static \EasyAlipay\Payment\Application payment(array $config)
20
 *
21
 * @author   liuml  <[email protected]>
22
 * @DateTime 2019-07-26  18:18
23
 */
24
class Alipay
25
{
26
    /**
27
     * make.
28
     *
29
     * @param       $name
30
     * @param array $config
31
     *
32
     * @return mixed
33
     *
34
     * @throws \EasyAlipay\Kernel\Exceptions\ApplicationException
35
     */
36 20
    public static function make($name, array $config)
37
    {
38 20
        $namespace = Str::studly($name);
39 20
        $application = __NAMESPACE__."\\{$namespace}\\Application";
40
41 20
        if (class_exists($application)) {
42
            // Instantiation application
43 20
            return new $application($config);
44
        }
45
        throw new ApplicationException("Application [{$name}] does not exist");
46
    }
47
48
    /**
49
     * Dynamically pass methods to the application.
50
     *
51
     * @param $name
52
     * @param $arguments
53
     *
54
     * @return mixed
55
     *
56
     * @throws \EasyAlipay\Kernel\Exceptions\ApplicationException
57
     */
58 20
    public static function __callStatic($name, $arguments)
59
    {
60 20
        return self::make($name, ...$arguments);
1 ignored issue
show
Bug introduced by
$arguments is expanded, but the parameter $config of EasyAlipay\Alipay::make() does not expect variable arguments. ( Ignorable by Annotation )

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

60
        return self::make($name, /** @scrutinizer ignore-type */ ...$arguments);
Loading history...
61
    }
62
}
63