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
Pull Request — master (#32)
by Charlotte
02:14
created

OkResponseMessage::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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