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

GetSubscriptionAttributeResponse   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 74
rs 10
c 0
b 0
f 0
wmc 12
1
<?php
2
namespace AliyunMNS\Responses;
3
4
use AliyunMNS\Constants;
5
use AliyunMNS\Model\SubscriptionAttributes;
6
use AliyunMNS\Exception\MnsException;
7
use AliyunMNS\Exception\SubscriptionNotExistException;
8
use AliyunMNS\Responses\BaseResponse;
9
use AliyunMNS\Common\XMLParser;
10
11
class GetSubscriptionAttributeResponse extends BaseResponse
12
{
13
    private $attributes;
14
15
    public function __construct()
16
    {
17
        $this->attributes = NULL;
18
    }
19
20
    public function getSubscriptionAttributes()
21
    {
22
        return $this->attributes;
23
    }
24
25
    public function parseResponse($statusCode, $content)
26
    {
27
        $this->statusCode = $statusCode;
28
        if ($statusCode == 200)
29
        {
30
            $this->succeed = TRUE;
31
        }
32
        else
33
        {
34
            $this->parseErrorResponse($statusCode, $content);
35
        }
36
37
        $xmlReader = $this->loadXmlContent($content);
38
39
        try
40
        {
41
            $this->attributes = SubscriptionAttributes::fromXML($xmlReader);
42
        }
43
        catch (\Exception $e)
44
        {
45
            throw new MnsException($statusCode, $e->getMessage(), $e);
46
        }
47
        catch (\Throwable $t)
48
        {
49
            throw new MnsException($statusCode, $t->getMessage());
50
        }
51
    }
52
53
    public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
54
    {
55
        $this->succeed = FALSE;
56
        $xmlReader = $this->loadXmlContent($content);
57
58
        try
59
        {
60
            $result = XMLParser::parseNormalError($xmlReader);
61
            if ($result['Code'] == Constants::SUBSCRIPTION_NOT_EXIST)
62
            {
63
                throw new SubscriptionNotExistException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
64
            }
65
            throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
66
        }
67
        catch (\Exception $e)
68
        {
69
            if ($exception != NULL)
70
            {
71
                throw $exception;
72
            }
73
            elseif ($e instanceof MnsException)
74
            {
75
                throw $e;
76
            }
77
            else
78
            {
79
                throw new MnsException($statusCode, $e->getMessage());
80
            }
81
        }
82
        catch (\Throwable $t)
83
        {
84
            throw new MnsException($statusCode, $t->getMessage());
85
        }
86
    }
87
}
88
?>
89