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

DeleteMessageErrorItem::fromXML()   C

Complexity

Conditions 11
Paths 11

Size

Total Lines 46
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 11
eloc 28
nc 11
nop 1
dl 0
loc 46
rs 5.2653
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace AliyunMNS\Model;
3
4
use AliyunMNS\Constants;
5
6
class DeleteMessageErrorItem
7
{
8
    protected $errorCode;
9
    protected $errorMessage;
10
    protected $receiptHandle;
11
12
    public function __construct($errorCode, $errorMessage, $receiptHandle)
13
    {
14
        $this->errorCode = $errorCode;
15
        $this->errorMessage = $errorMessage;
16
        $this->receiptHandle = $receiptHandle;
17
    }
18
19
    public function getErrorCode()
20
    {
21
        return $this->errorCode;
22
    }
23
24
    public function getErrorMessage()
25
    {
26
        return $this->errorMessage;
27
    }
28
29
    public function getReceiptHandle()
30
    {
31
        return $this->receiptHandle;
32
    }
33
34
    static public function fromXML($xmlReader)
35
    {
36
        $errorCode = NULL;
37
        $errorMessage = NULL;
38
        $receiptHandle = NULL;
39
40
        while ($xmlReader->read())
41
        {
42
            switch ($xmlReader->nodeType)
43
            {
44
            case \XMLReader::ELEMENT:
45
                switch ($xmlReader->name)
46
                {
47
                case Constants::ERROR_CODE:
48
                    $xmlReader->read();
49
                    if ($xmlReader->nodeType == \XMLReader::TEXT)
50
                    {
51
                        $errorCode = $xmlReader->value;
52
                    }
53
                    break;
54
                case Constants::ERROR_MESSAGE:
55
                    $xmlReader->read();
56
                    if ($xmlReader->nodeType == \XMLReader::TEXT)
57
                    {
58
                        $errorMessage = $xmlReader->value;
59
                    }
60
                    break;
61
                case Constants::RECEIPT_HANDLE:
62
                    $xmlReader->read();
63
                    if ($xmlReader->nodeType == \XMLReader::TEXT)
64
                    {
65
                        $receiptHandle = $xmlReader->value;
66
                    }
67
                    break;
68
                }
69
                break;
70
            case \XMLReader::END_ELEMENT:
71
                if ($xmlReader->name == Constants::ERROR)
72
                {
73
                    return new DeleteMessageErrorItem($errorCode, $errorMessage, $receiptHandle);
74
                }
75
                break;
76
            }
77
        }
78
79
        return new DeleteMessageErrorItem($errorCode, $errorMessage, $receiptHandle);
80
    }
81
}
82
83
?>
84