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 — master ( d88fce...019e6b )
by Alexander
03:10
created

ServiceClient::readFeedback()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * (c) Alexander Zhukov <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Zbox\UnifiedPush\NotificationService\MPNS;
11
12
use Zbox\UnifiedPush\NotificationService\ServiceClientBase;
13
use Zbox\UnifiedPush\Exception\ClientException;
14
use Buzz\Browser;
15
use Buzz\Client\MultiCurl;
16
17
/**
18
 * Class ServiceClient
19
 * @package Zbox\UnifiedPush\NotificationService\MPNS
20
 */
21
class ServiceClient extends ServiceClientBase
22
{
23
    /**
24
     * Initializing HTTP client
25
     *
26
     * @return $this
27
     */
28
    protected function createClient()
29
    {
30
        $client = new MultiCurl();
31
32
        $credentials      = $this->getCredentials();
33
        $isAuthenticated  = $credentials->isAuthenticated();
34
35
        $client->setVerifyPeer($isAuthenticated);
36
37
        if ($isAuthenticated) {
38
            $client->setOption(CURLOPT_SSLCERT, $credentials->getCertificatePassPhrase());
39
            $client->setOption(CURLOPT_SSLCERTPASSWD, $credentials->getCertificatePassPhrase());
40
        }
41
42
        $this->serviceClient = new Browser($client);
43
44
        return $this;
45
    }
46
47
    /**
48
     * @throws ClientException
49
     * @return bool
50
     */
51
    public function sendRequest()
52
    {
53
        $notification = $this->getNotificationOrThrowException();
54
55
        try {
56
            $connection  = $this->getClientConnection();
57
            $serviceURL  = $this->getServiceURL();
58
            $url         = str_replace('[TOKEN]', $notification['recipients'][0], $serviceURL['url']);
59
60
            $headers = array();
61
            $headers[] = 'Accept: application/*';
62
            $headers[] = 'Content-Type: text/xml';
63
64
            foreach ($notification['options'] as $key => $value) {
65
                $headers[] = $key . ': ' . $value;
66
            }
67
68
            $response = $connection->post($url, $headers, $notification['body']);
69
            $connection->getClient()->flush();
70
71
        } catch (\Exception $e) {
72
            throw new ClientException($e->getMessage());
73
        }
74
75
        new Response($response, $notification['recipients']);
76
77
        return true;
78
    }
79
}
80