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.
Test Failed
Push — master ( d54200...f2da15 )
by Charlotte
03:55
created

OkResponseMessage::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Plasma Driver MySQL component
4
 * Copyright 2018 PlasmaPHP, All Rights Reserved
5
 *
6
 * Website: https://github.com/PlasmaPHP
7
 * License: https://github.com/PlasmaPHP/driver-mysql/blob/master/LICENSE
8
*/
9
10
namespace Plasma\Drivers\MySQL\Messages;
11
12
/**
13
 * Represents a Ok Response Message.
14
 * @internal
15
 */
16
class OkResponseMessage implements \Plasma\Drivers\MySQL\Messages\MessageInterface {
17
    /**
18
     * Count of affected rows by the last query.
19
     * @var int
20
     */
21
    public $affectedRows;
22
    
23
    /**
24
     * Last inserted ID by the last `INSERT` query.
25
     * @var int
26
     */
27
    public $lastInsertedID;
28
    
29
    /**
30
     * The server status flags.
31
     * @var int
32
     * @see \Plasma\Drivers\MySQL\StatusFlags
33
     */
34
    public $statusFlags;
35
    
36
    /**
37
     * Count of warnings.
38
     * @var int
39
     */
40
    public $warningsCount;
41
    
42
    /**
43
     * Server session information, if any.
44
     * @var string|null
45
     */
46
    public $sessionInfo;
47
    
48
    /**
49
     * Server session state changes, if any.
50
     * @var string|null
51
     */
52
    public $sessionStateChanges;
53
    
54
    /**
55
     * Human readable status information, if any.
56
     * @var string|null
57
     */
58
    public $info;
59
    
60
    /**
61
     * @var \Plasma\Drivers\MySQL\ProtocolParser
62
     */
63
    protected $parser;
64
    
65
    /**
66
     * Constructor.
67
     * @param \Plasma\Drivers\MySQL\ProtocolParser  $parser
68
     */
69 10
    function __construct(\Plasma\Drivers\MySQL\ProtocolParser $parser) {
70 10
        $this->parser = $parser;
71 10
    }
72
    
73
    /**
74
     * Get the identifier for the packet.
75
     * @return string
76
     */
77
    static function getID(): string {
78
        return "\x00";
79
    }
80
    
81
    /**
82
     * Parses the message, once the complete string has been received.
83
     * Returns false if not enough data has been received, or the remaining buffer.
84
     * @param string  $buffer
85
     * @return string|bool
86
     * @throws \Plasma\Drivers\MySQL\Messages\ParseException
87
     */
88 10
    function parseMessage(string $buffer) {
89 10
        $nameLength = \strpos($buffer, "\x00");
90 10
        if($nameLength === false) {
91
            return false;
92
        }
93
        
94 10
        $affectedRows = \Plasma\Drivers\MySQL\Messages\MessageUtility::readIntLength($buffer);
95 10
        $lastInsertedID = \Plasma\Drivers\MySQL\Messages\MessageUtility::readIntLength($buffer);
96
        
97 10
        $handshake = $this->parser->getHandshakeMessage();
98 10
        if(!$handshake) {
99
            throw new \Plasma\Drivers\MySQL\Messages\ParseException('No handshake message when receiving ok response packet');
100
        }
101
        
102 10
        $statusFlags = \Plasma\Drivers\MySQL\Messages\MessageUtility::readInt2($buffer);
103 10
        $warningsCount = \Plasma\Drivers\MySQL\Messages\MessageUtility::readInt2($buffer);
104
        
105 10
        if(($handshake->capability & \Plasma\Drivers\MySQL\CapabilityFlags::CLIENT_SESSION_TRACK) !== 0) {
106
            $sessionInfo = \Plasma\Drivers\MySQL\Messages\MessageUtility::readStringLength($buffer);
107
            
108
            if(($statusFlags & \Plasma\Drivers\MySQL\StatusFlags::SERVER_SESSION_STATE_CHANGED) !== 0) {
109
                $sessionStateChanges = \Plasma\Drivers\MySQL\Messages\MessageUtility::readStringLength($buffer);
110
            } else {
111
                $sessionStateChanges = null;
112
            }
113
            
114
            $info = null;
115
        } else {
116 10
            $sessionInfo = null;
117 10
            $sessionStateChanges = null;
118 10
            $info = $buffer;
119
        }
120
        
121 10
        $this->affectedRows = $affectedRows;
122 10
        $this->lastInsertedID = $lastInsertedID;
123
        
124 10
        $this->statusFlags = $statusFlags;
125 10
        $this->warningsCount = $warningsCount;
126
        
127 10
        $this->sessionInfo = $sessionInfo;
128 10
        $this->sessionStateChanges = $sessionStateChanges;
129 10
        $this->info = $info;
130
        
131 10
        return $buffer;
132
    }
133
    
134
    /**
135
     * Get the parser which created this message.
136
     * @return \Plasma\Drivers\MySQL\ProtocolParser
137
     */
138 2
    function getParser(): \Plasma\Drivers\MySQL\ProtocolParser {
139 2
        return $this->parser;
140
    }
141
    
142
    /**
143
     * Sets the parser state, if necessary. If not, return `-1`.
144
     * @return int
145
     */
146 10
    function setParserState(): int {
147 10
        return \Plasma\Drivers\MySQL\ProtocolParser::STATE_OK;
148
    }
149
}
150