Completed
Push — master ( f77f61...4f79b1 )
by wannanbigpig
02:51 queued 11s
created

Alipay   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __callStatic() 0 3 1
A make() 0 10 2
1
<?php
2
/*
3
 * This file is part of the wannanbigpig/alipay-sdk-php.
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 string $name
30
     * @param array  $config
31
     *
32
     * @return mixed
33
     *
34
     * @throws \EasyAlipay\Kernel\Exceptions\ApplicationException
35
     */
36 44
    public static function make(string $name, array $config)
37
    {
38 44
        $namespace = Str::studly($name);
39 44
        $application = __NAMESPACE__."\\{$namespace}\\Application";
40
41 44
        if (class_exists($application)) {
42
            // Instantiation application
43 42
            return new $application($config);
44
        }
45 2
        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 44
    public static function __callStatic($name, $arguments)
59
    {
60 44
        return self::make($name, ...$arguments);
61
    }
62
}
63