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 ( 9a7ea4...53d770 )
by Yang
02:32
created

DeleteTopicResponse   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 3
dl 37
loc 37
rs 10

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace AliyunMNS\Responses;
3
4
use AliyunMNS\Exception\MnsException;
5
use AliyunMNS\Responses\BaseResponse;
6
use AliyunMNS\Common\XMLParser;
7
8
class DeleteTopicResponse extends BaseResponse
9
{
10
    public function __construct()
11
    {
12
    }
13
14
    public function parseResponse($statusCode, $content)
15
    {
16
        $this->statusCode = $statusCode;
17
        if ($statusCode == 204) {
18
            $this->succeed = TRUE;
19
        } else {
20
            $this->parseErrorResponse($statusCode, $content);
21
        }
22
    }
23
24
    public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
25
    {
26
        $this->succeed = FALSE;
27
        $xmlReader = new \XMLReader();
28
        try {
29
            $xmlReader->XML($content);
30
            $result = XMLParser::parseNormalError($xmlReader);
31
            throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
32
        } catch (\Exception $e) {
33
            if ($exception != NULL) {
34
                throw $exception;
35
            } elseif($e instanceof MnsException) {
36
                throw $e;
37
            } else {
38
                throw new MnsException($statusCode, $e->getMessage());
39
            }
40
        } catch (\Throwable $t) {
41
            throw new MnsException($statusCode, $t->getMessage());
42
        }
43
    }
44
}
45
46
?>
47