Passed
Pull Request — master (#1179)
by Keal
03:20
created

Client::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: keal
5
 * Date: 2018/4/3
6
 * Time: 下午2:53
7
 */
8
9
namespace EasyWeChat\OpenPlatform\Authorizer\OfficialAccount\Auth;
10
11
12
use EasyWeChat\Kernel\BaseClient;
13
use EasyWeChat\Kernel\ServiceContainer;
14
use EasyWeChat\OpenPlatform\Application;
15
16
class Client extends BaseClient
17
{
18
    /**
19
     * @var \EasyWeChat\OpenPlatform\Application
20
     */
21
    protected $component;
22
23
    /**
24
     * Client constructor.
25
     *
26
     * @param \EasyWeChat\Kernel\ServiceContainer  $app
27
     * @param \EasyWeChat\OpenPlatform\Application $component
28
     */
29
    public function __construct(ServiceContainer $app, Application $component)
30
    {
31
        parent::__construct($app);
32
33
        $this->component = $component;
34
    }
35
36
    /**
37
     * 从第三方平台跳转至微信公众平台授权注册页面, 授权注册小程序.
38
     *
39
     * @param string $callbackUrl
40
     * @param bool $copyWxVerify
41
     *
42
     * @return string
43
     */
44
    public function getPreAuthorizationUrl(string $callbackUrl, bool $copyWxVerify = true) : string
45
    {
46
        $queries = [
47
            'copy_wx_verify' => $copyWxVerify ? 1 : 0,
48
            'component_appid' => $this->component['config']['app_id'],
49
            'appid' => $this->app['config']['app_id'],
50
            'redirect_uri' => $callbackUrl,
51
        ];
52
53
        return 'https://mp.weixin.qq.com/cgi-bin/fastregisterauth?'.http_build_query($queries);
54
    }
55
}