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

GetTopicAttributeResponse   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 73
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\TopicAttributes;
6
use AliyunMNS\Exception\MnsException;
7
use AliyunMNS\Exception\TopicNotExistException;
8
use AliyunMNS\Responses\BaseResponse;
9
use AliyunMNS\Common\XMLParser;
10
11
class GetTopicAttributeResponse extends BaseResponse
12
{
13
    private $attributes;
14
15
    public function __construct()
16
    {
17
        $this->attributes = NULL;
18
    }
19
20
    public function getTopicAttributes()
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
            $this->attributes = TopicAttributes::fromXML($xmlReader);
41
        }
42
        catch (\Exception $e)
43
        {
44
            throw new MnsException($statusCode, $e->getMessage(), $e);
45
        }
46
        catch (\Throwable $t)
47
        {
48
            throw new MnsException($statusCode, $t->getMessage());
49
        }
50
    }
51
52
    public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
53
    {
54
        $this->succeed = FALSE;
55
        $xmlReader = $this->loadXmlContent($content);
56
57
        try
58
        {
59
            $result = XMLParser::parseNormalError($xmlReader);
60
            if ($result['Code'] == Constants::TOPIC_NOT_EXIST)
61
            {
62
                throw new TopicNotExistException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
63
            }
64
            throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
65
        }
66
        catch (\Exception $e)
67
        {
68
            if ($exception != NULL)
69
            {
70
                throw $exception;
71
            }
72
            elseif ($e instanceof MnsException)
73
            {
74
                throw $e;
75
            }
76
            else
77
            {
78
                throw new MnsException($statusCode, $e->getMessage());
79
            }
80
        }
81
        catch (\Throwable $t)
82
        {
83
            throw new MnsException($statusCode, $t->getMessage());
84
        }
85
    }
86
}
87
88
?>
89