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.
Completed
Push — rewrite ( 0fb4ce...6a38b9 )
by Adam
03:05
created

Client::getPonyfmUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Poniverse\Lib;
4
5
use GuzzleHttp\Client as HttpClient;
6
use League\OAuth2\Client\Token\AccessToken;
7
use Poniverse\Lib\OAuth2\PoniverseProvider;
8
9
class Client
10
{
11
    /**
12
     * @var string|null
13
     */
14
    protected $accessToken = null;
15
16
    /**
17
     * @var \GuzzleHttp\Client
18
     */
19
    protected $httpClient;
20
21
    /**
22
     * Poniverse.net Client ID.
23
     *
24
     * @var string
25
     */
26
    private $clientId;
27
28
    /**
29
     * Poniverse.net Client Secret.
30
     *
31
     * @var string
32
     */
33
    private $clientSecret;
34
35
    protected $poniverseUrl = 'http://api.poniverse.local';
36
    protected $ponyfmUrl = 'https://pony.fm';
37
38
    /**
39
     * Initializes the Poniverse Api client.
40
     *
41
     * @param string $clientId
42
     * @param string $clientSecret
43
     * @param \GuzzleHttp\Client $httpClient
44
     */
45
    public function __construct($clientId, $clientSecret, HttpClient $httpClient)
46
    {
47
        $this->clientId = $clientId;
48
        $this->clientSecret = $clientSecret;
49
        $this->httpClient = $httpClient;
50
    }
51
52
    /**
53
     * Returns the set access key.
54
     *
55
     * @return string
56
     */
57
    public function getAccessToken()
58
    {
59
        return $this->accessToken;
60
    }
61
62
    /**
63
     * Sets the access token to communicate to the api with.
64
     *
65
     * @param $accessToken
66
     *
67
     * @return $this
68
     */
69
    public function setAccessToken(AccessToken $accessToken)
70
    {
71
        $this->accessToken = $accessToken->getToken();
72
73
        return $this;
74
    }
75
76
    /**
77
     * Returns the http client.
78
     *
79
     * @return \GuzzleHttp\Client
80
     */
81
    public function getHttpClient()
82
    {
83
        return $this->httpClient;
84
    }
85
86
    public function getAuthHeader()
87
    {
88
        return ['Authorization' => 'Bearer '.$this->getAccessToken()];
89
    }
90
91
    public function getPoniverseUrl()
92
    {
93
        return $this->poniverseUrl;
94
    }
95
96
    public function getPonyfmUrl()
97
    {
98
        return $this->ponyfmUrl;
99
    }
100
101
    /**
102
     * Returns the Poniverse OAuth Provider class.
103
     *
104
     * @param array $options
105
     * @return PoniverseProvider
106
     */
107
    public function getOAuthProvider(array $options = [])
108
    {
109
        $options = array_merge([
110
            'clientId' => $this->clientId,
111
            'clientSecret' => $this->clientSecret,
112
        ], $options);
113
114
        return new PoniverseProvider($options);
115
    }
116
}
117