Passed
Pull Request — master (#638)
by
unknown
01:54
created

InvokePrepayPlugin::getAppid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 4
c 1
b 1
f 0
dl 0
loc 9
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Wechat\Pay\Jsapi;
6
7
use Yansongda\Pay\Rocket;
8
use Yansongda\Pay\Pay;
9
10
class InvokePrepayPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\InvokePrepayPlugin
11
{
12
    /**
13
     * @throws \Yansongda\Pay\Exception\ContainerException
14
     * @throws \Yansongda\Pay\Exception\ServiceNotFoundException
15
     */
16
    protected function getAppid(Rocket $rocket): string
17
    {
18
        $config = get_wechat_config($rocket->getParams());
19
20
        if (Pay::MODE_SERVICE == $config->get('mode')) {
21
            return $rocket->getPayload()->get('sub_appid', $config->get('sub_mp_app_id', ''));
22
        }
23
24
        return $config->get('mp_app_id', '');
25
    }
26
}
27