Completed
Push — master ( 737524...d40843 )
by Songda
07:36 queued 11s
created

Functions.php ➔ get_wechat_config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 8
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
use Yansongda\Pay\Contract\ConfigInterface;
6
use Yansongda\Pay\Pay;
7
use Yansongda\Supports\Config;
8
9
if (!function_exists('get_alipay_config')) {
10
    /**
11
     * @throws \Yansongda\Pay\Exception\ContainerDependencyException
12
     * @throws \Yansongda\Pay\Exception\ContainerException
13
     * @throws \Yansongda\Pay\Exception\ServiceNotFoundException
14
     */
15 View Code Duplication
    function get_alipay_config(array $params): Config
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
    {
17
        $alipay = Pay::get(ConfigInterface::class)->get('alipay');
18
19
        $config = $params['_config'] ?? 'default';
20
21
        return new Config($alipay[$config] ?? []);
22
    }
23
}
24
25
if (!function_exists('get_wechat_config')) {
26
    /**
27
     * @throws \Yansongda\Pay\Exception\ContainerDependencyException
28
     * @throws \Yansongda\Pay\Exception\ContainerException
29
     * @throws \Yansongda\Pay\Exception\ServiceNotFoundException
30
     */
31 View Code Duplication
    function get_wechat_config(array $params): array
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $wechat = Pay::get(ConfigInterface::class)->get('wechat');
34
35
        $config = $params['_config'] ?? 'default';
36
37
        return $wechat[$config] ?? [];
38
    }
39
}
40