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.
Passed
Branch master (b10c57)
by milkmeowo
02:58
created

MnsPromise   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 7
1
<?php
2
namespace AliyunMNS\Responses;
3
4
use GuzzleHttp\Promise\PromiseInterface;
5
use AliyunMNS\Responses\BaseResponse;
6
use AliyunMNS\Exception\MnsException;
7
use GuzzleHttp\Exception\TransferException;
8
use Psr\Http\Message\ResponseInterface;
9
10
class MnsPromise
11
{
12
    private $response;
13
    private $promise;
14
15
    public function __construct(PromiseInterface &$promise, BaseResponse &$response)
16
    {
17
        $this->promise = $promise;
18
        $this->response = $response;
19
    }
20
21
    public function isCompleted()
22
    {
23
        return $this->promise->getState() != 'pending';
24
    }
25
26
    public function getResponse()
27
    {
28
        return $this->response;
29
    }
30
31
    public function wait()
32
    {
33
        try {
34
            $res = $this->promise->wait();
35
            if ($res instanceof ResponseInterface)
36
            {
37
                $this->response->parseResponse($res->getStatusCode(), $res->getBody());
38
            }
39
        } catch (TransferException $e) {
40
            $message = $e->getMessage();
41
            if ($e->hasResponse()) {
42
                $message = $e->getResponse()->getBody();
43
            }
44
            $this->response->parseErrorResponse($e->getCode(), $message);
45
        }
46
        return $this->response;
47
    }
48
}
49
50
?>
51