Completed
Pull Request — master (#51)
by mingyoung
03:53 queued 01:32
created

WeChatOpenPlatformProvider::getCodeFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the overtrue/socialite.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Overtrue\Socialite\Providers;
13
14
use Symfony\Component\HttpFoundation\Request;
15
16
/**
17
 * Class WeChatProvider.
18
 *
19
 * @link https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419318590&token=&lang=zh_CN [WeChat - 公众开放平台代公众号 OAuth 文档]
20
 */
21
class WeChatOpenPlatformProvider extends WeChatProvider
22
{
23
    /**
24
     * Component AppId.
25
     *
26
     * @var string
27
     */
28
    protected $componentAppId;
29
30
    /**
31
     * Component Access Token.
32
     *
33
     * @var string
34
     */
35
    protected $componentAccessToken;
36
37
    /**
38
     * {@inheritdoc}.
39
     */
40
    protected $scopes = ['snsapi_base'];
41
42
    /**
43
     * Create a new provider instance.
44
     * (Overriding).
45
     *
46
     * @param \Symfony\Component\HttpFoundation\Request $request
47
     * @param string                                    $clientId
48
     * @param array                                     $componentCredits
0 ignored issues
show
Bug introduced by
There is no parameter named $componentCredits. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
49
     * @param string|null                               $redirectUrl
50
     */
51
    public function __construct(Request $request, $clientId, array $componentCredentials, $redirectUrl = null)
52
    {
53
        parent::__construct($request, $clientId, null, $redirectUrl);
54
55
        list($this->componentAppId, $this->componentAccessToken) = $componentCredentials;
56
    }
57
58
    /**
59
     * {@inheritdoc}.
60
     */
61
    public function getCodeFields($state = null)
62
    {
63
        $this->with(['component_appid' => $this->componentAppId]);
64
65
        return parent::getCodeFields($state);
66
    }
67
68
    /**
69
     * {@inheritdoc}.
70
     */
71
    protected function getTokenUrl()
72
    {
73
        return $this->baseUrl.'/oauth2/component/access_token';
74
    }
75
76
    /**
77
     * {@inheritdoc}.
78
     */
79
    protected function getTokenFields($code)
80
    {
81
        return [
82
            'appid' => $this->clientId,
83
            'component_appid' => $this->componentAppId,
84
            'component_access_token' => $this->componentAccessToken,
85
            'code' => $code,
86
            'grant_type' => 'authorization_code',
87
        ];
88
    }
89
}
90