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.

YandexWebmasterOAuth   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 1
A saveAccessToken() 0 4 1
A restoreAccessToken() 0 11 3
1
<?php
2
3
namespace app\backend\clients;
4
5
use app\backend\models\ApiService;
6
use Yii;
7
use yii\authclient\OAuthToken;
8
9
class YandexWebmasterOAuth extends \yii\authclient\clients\YandexOAuth
10
{
11
12
    public $hostId;
13
14
    public function init()
15
    {
16
        parent::init();
17
        $this->apiBaseUrl = "https://webmaster.yandex.ru/api/v2/hosts/{$this->hostId}";
18
    }
19
20
    /**
21
     * Saves token in DB.
22
     * @param OAuthToken $token
23
     * @return ApiService|null|\yii\db\ActiveQuery|\yii\db\ActiveRecord|static
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use null|\yii\db\ActiveQuery|\yii\db\ActiveRecord.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
24
     */
25
    protected function saveAccessToken(OAuthToken $token)
26
    {
27
        return ApiService::saveToken($this->id, $token);
28
    }
29
30
    /**
31
     * Restores access token.
32
     * @return OAuthToken auth token.
33
     */
34
    protected function restoreAccessToken()
35
    {
36
        $token = ApiService::getToken($this->id);
37
        if (is_object($token)) {
38
            /* @var $token OAuthToken */
39
            if ($token->getIsExpired()) {
40
                $token = $this->refreshAccessToken($token);
41
            }
42
        }
43
        return $token;
44
    }
45
}
46