GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — filters ( 9453cb...fb817b )
by
unknown
13:00
created

PayPal::initUserAttributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4286
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
3
namespace app\modules\user\authclients;
4
5
6
use yii\authclient\OAuth2;
7
8
/**
9
 *
10
 * Write return_url in PayPal setting page http::/your-site.name/user/user/auth?authclient=PayPal&scope=openid
11
 *
12
 * Class PayPal
13
 * @package app\modules\user\authclients
14
 */
15
class PayPal extends OAuth2
16
{
17
18
    const URI_SANDBOX = "https://api.sandbox.paypal.com/v1/";
19
    const URI_LIVE = "https://api.paypal.com/v1/";
20
    const URI_AUTHORIZE_LIVE = 'https://www.paypal.com/';
21
    const URI_AUTHORIZE_SANDBOX = 'https://www.sandbox.paypal.com/';
22
23
    public $debug = false;
24
25
    public $scope = 'openid';
26
27
    public $authUrl = 'webapps/auth/protocol/openidconnect/v1/authorize';
28
29
    public $tokenUrl = 'identity/openidconnect/tokenservice';
30
31
32
    /**
33
     * Composes user authorization URL.
34
     * @param array $params additional auth GET params.
35
     * @return string authorization URL.
36
     */
37
    public function buildAuthUrl(array $params = [])
38
    {
39
        $defaultParams = [
40
            'client_id' => $this->clientId,
41
            'redirect_uri' => $this->getReturnUrl() . '&scope=openid',
42
            'response_type' => 'code',
43
        ];
44
        if (!empty($this->scope)) {
45
            $defaultParams['scope'] = $this->scope;
46
        }
47
        return $this->composeUrl($this->authUrl, array_merge($defaultParams, $params));
48
    }
49
50
    public function init()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
51
    {
52
        if ($this->debug) {
53
            $this->tokenUrl = self::URI_SANDBOX . $this->tokenUrl;
54
            $this->authUrl = self::URI_AUTHORIZE_SANDBOX . $this->authUrl;
55
        } else {
56
            $this->tokenUrl = self::URI_LIVE . $this->tokenUrl;
57
            $this->authUrl = self::URI_AUTHORIZE_LIVE . $this->authUrl;
58
        }
59
        return parent::init();
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65
    protected function defaultName()
66
    {
67
        return 'paypal';
68
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73
    protected function defaultTitle()
74
    {
75
        return 'PayPal';
76
    }
77
78
79
    /**
80
     * @inheritdoc
81
     */
82
    public function defaultViewOptions()
83
    {
84
        return [
85
            'popupWidth' => 1000,
86
            'popupHeight' => 600,
87
        ];
88
    }
89
90
    public function initUserAttributes()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
91
    {
92
        $url = $this->debug ? self::URI_SANDBOX : self::URI_LIVE;
93
        return $this->api(
94
            $url . 'identity/openidconnect/userinfo/?schema=openid',
95
            'GET',
96
            [
97
                'headers' => [
98
                    'Authorization' => 'Bearer ' . $this->accessToken->token,
99
                ]
100
101
            ]);
102
    }
103
104
}