Completed
Push — master ( 8787ba...721c87 )
by wannanbigpig
05:01 queued 11s
created

Alipay   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
eloc 7
c 3
b 0
f 2
dl 0
loc 37
ccs 7
cts 8
cp 0.875
rs 10
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.
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 WannanBigPig\Alipay;
12
13
use WannanBigPig\Alipay\Kernel\Exceptions\ApplicationException;
14
use WannanBigPig\Supports\Str;
15
16
/**
17
 * Class Alipay
18
 *
19
 * @method static \WannanBigPig\Alipay\Payment\Application payment(array $config)
20
 *
21
 * @author   liuml  <[email protected]>
22
 * @DateTime 2019-07-15  11:46
23
 *
24
 * @package  WannanBigPig\Alipay
25
 */
26
class Alipay
27
{
28
    /**
29
     * make.
30
     *
31
     * @param       $name
32
     * @param array $config
33
     *
34
     * @return mixed
35
     *
36
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\ApplicationException
37
     */
38 20
    public static function make($name, array $config)
39
    {
40 20
        $namespace = Str::studly($name);
41 20
        $application = __NAMESPACE__."\\{$namespace}\\Application";
42
43 20
        if (class_exists($application)) {
44
            // Instantiation application
45 20
            return new $application($config);
46
        }
47
        throw new ApplicationException("Application [{$name}] does not exist");
48
    }
49
50
    /**
51
     * Dynamically pass methods to the application.
52
     *
53
     * @param $name
54
     * @param $arguments
55
     *
56
     * @return mixed
57
     *
58
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\ApplicationException
59
     */
60 20
    public static function __callStatic($name, $arguments)
61
    {
62 20
        return self::make($name, ...$arguments);
0 ignored issues
show
Bug introduced by
$arguments is expanded, but the parameter $config of WannanBigPig\Alipay\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

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