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
Push — master ( f731b0...b5a8f2 )
by Charlotte
02:33
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-2019 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 58
    function __construct(\Plasma\Drivers\MySQL\ProtocolParser $parser) {
70 58
        $this->parser = $parser;
71 58
    }
72
    
73
    /**
74
     * Get the identifier for the packet.
75
     * @return string
76
     */
77 59
    static function getID(): string {
78 59
        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 \Plasma\BinaryBuffer  $buffer
85
     * @return bool
86
     * @throws \Plasma\Drivers\MySQL\Messages\ParseException
87
     */
88 58
    function parseMessage(\Plasma\BinaryBuffer $buffer): bool {
89
        try {
90 58
            $handshake = $this->parser->getHandshakeMessage();
91 58
            if(!$handshake) {
92
                throw new \Plasma\Drivers\MySQL\Messages\ParseException('No handshake message when receiving ok response packet');
93
            }
94
            
95 58
            $this->affectedRows = $buffer->readIntLength();
96 58
            $this->lastInsertedID = $buffer->readIntLength();
97
            
98 58
            $this->statusFlags = $buffer->readInt2();
99 58
            $this->warningsCount = $buffer->readInt2();
100
            
101 58
            if(($handshake->capability & \Plasma\Drivers\MySQL\CapabilityFlags::CLIENT_SESSION_TRACK) !== 0) {
102 58
                if($buffer->getSize() > 0) {
103
                    $this->sessionInfo = $buffer->readStringLength();
104
                    
105
                    if(($this->statusFlags & \Plasma\Drivers\MySQL\StatusFlags::SERVER_SESSION_STATE_CHANGED) !== 0) {
106 58
                        $this->sessionStateChanges = $buffer->readStringLength();
107
                    }
108
                }
109
            } else {
110
                $this->info = $buffer->getContents();
111
                $buffer->clear();
112
            }
113
            
114 58
            return true;
115
        } catch (\OverflowException $e) {
116
            return false;
117
        }
118
    }
119
    
120
    /**
121
     * Get the parser which created this message.
122
     * @return \Plasma\Drivers\MySQL\ProtocolParser
123
     */
124 56
    function getParser(): \Plasma\Drivers\MySQL\ProtocolParser {
125 56
        return $this->parser;
126
    }
127
    
128
    /**
129
     * Sets the parser state, if necessary. If not, return `-1`.
130
     * @return int
131
     */
132 58
    function setParserState(): int {
133 58
        return \Plasma\Drivers\MySQL\ProtocolParser::STATE_OK;
134
    }
135
}
136