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

Topic   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 99
rs 10
c 0
b 0
f 0
wmc 15
1
<?php
2
namespace AliyunMNS;
3
4
use AliyunMNS\Http\HttpClient;
5
use AliyunMNS\AsyncCallback;
6
use AliyunMNS\Model\TopicAttributes;
7
use AliyunMNS\Model\SubscriptionAttributes;
8
use AliyunMNS\Model\UpdateSubscriptionAttributes;
9
use AliyunMNS\Requests\SetTopicAttributeRequest;
10
use AliyunMNS\Responses\SetTopicAttributeResponse;
11
use AliyunMNS\Requests\GetTopicAttributeRequest;
12
use AliyunMNS\Responses\GetTopicAttributeResponse;
13
use AliyunMNS\Requests\PublishMessageRequest;
14
use AliyunMNS\Responses\PublishMessageResponse;
15
use AliyunMNS\Requests\SubscribeRequest;
16
use AliyunMNS\Responses\SubscribeResponse;
17
use AliyunMNS\Requests\UnsubscribeRequest;
18
use AliyunMNS\Responses\UnsubscribeResponse;
19
use AliyunMNS\Requests\GetSubscriptionAttributeRequest;
20
use AliyunMNS\Responses\GetSubscriptionAttributeResponse;
21
use AliyunMNS\Requests\SetSubscriptionAttributeRequest;
22
use AliyunMNS\Responses\SetSubscriptionAttributeResponse;
23
use AliyunMNS\Requests\ListSubscriptionRequest;
24
use AliyunMNS\Responses\ListSubscriptionResponse;
25
26
class Topic
27
{
28
    private $topicName;
29
    private $client;
30
31
    public function __construct(HttpClient $client, $topicName)
32
    {
33
        $this->client = $client;
34
        $this->topicName = $topicName;
35
    }
36
37
    public function getTopicName()
38
    {
39
        return $this->topicName;
40
    }
41
42
    public function setAttribute(TopicAttributes $attributes)
43
    {
44
        $request = new SetTopicAttributeRequest($this->topicName, $attributes);
45
        $response = new SetTopicAttributeResponse();
46
        return $this->client->sendRequest($request, $response);
47
    }
48
49
    public function getAttribute()
50
    {
51
        $request = new GetTopicAttributeRequest($this->topicName);
52
        $response = new GetTopicAttributeResponse();
53
        return $this->client->sendRequest($request, $response);
54
    }
55
56
    public function generateQueueEndpoint($queueName)
57
    {
58
        return "acs:mns:" . $this->client->getRegion() . ":" . $this->client->getAccountId() . ":queues/" . $queueName;
59
    }
60
61
    public function generateMailEndpoint($mailAddress)
62
    {
63
        return "mail:directmail:" . $mailAddress;
64
    }
65
66
    public function generateSmsEndpoint($phone = null)
67
    {
68
        if ($phone)
69
        {
70
            return "sms:directsms:" . $phone;
71
        }
72
        else
73
        {
74
            return "sms:directsms:anonymous";
75
        }
76
    }
77
78
    public function generateBatchSmsEndpoint()
79
    {
80
        return "sms:directsms:anonymous";
81
    }
82
83
    public function publishMessage(PublishMessageRequest $request)
84
    {
85
        $request->setTopicName($this->topicName);
86
        $response = new PublishMessageResponse();
87
        return $this->client->sendRequest($request, $response);
88
    }
89
90
    public function subscribe(SubscriptionAttributes $attributes)
91
    {
92
        $attributes->setTopicName($this->topicName);
93
        $request = new SubscribeRequest($attributes);
94
        $response = new SubscribeResponse();
95
        return $this->client->sendRequest($request, $response);
96
    }
97
98
    public function unsubscribe($subscriptionName)
99
    {
100
        $request = new UnsubscribeRequest($this->topicName, $subscriptionName);
101
        $response = new UnsubscribeResponse();
102
        return $this->client->sendRequest($request, $response);
103
    }
104
105
    public function getSubscriptionAttribute($subscriptionName)
106
    {
107
        $request = new GetSubscriptionAttributeRequest($this->topicName, $subscriptionName);
108
        $response = new GetSubscriptionAttributeResponse();
109
        return $this->client->sendRequest($request, $response);
110
    }
111
112
    public function setSubscriptionAttribute(UpdateSubscriptionAttributes $attributes)
113
    {
114
        $attributes->setTopicName($this->topicName);
115
        $request = new SetSubscriptionAttributeRequest($attributes);
116
        $response = new SetSubscriptionAttributeResponse();
117
        return $this->client->sendRequest($request, $response);
118
    }
119
120
    public function listSubscription($retNum = NULL, $prefix = NULL, $marker = NULL)
121
    {
122
        $request = new ListSubscriptionRequest($this->topicName, $retNum, $prefix, $marker);
123
        $response = new ListSubscriptionResponse();
124
        return $this->client->sendRequest($request, $response);
125
    }
126
}
127
128
?>
129