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 ( 18c025...2702d5 )
by Charlotte
03:32
created

EOFMessage   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 12.5%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 68
ccs 2
cts 16
cp 0.125
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getParser() 0 2 1
A setParserState() 0 2 1
A getID() 0 2 1
A parseMessage() 0 10 2
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 an EOF Message.
14
 * @internal
15
 */
16
class EOFMessage implements \Plasma\Drivers\MySQL\Messages\MessageInterface {
17
    /**
18
     * The server status flags.
19
     * @var int
20
     * @see \Plasma\Drivers\MySQL\StatusFlags
21
     */
22
    public $statusFlags;
23
    
24
    /**
25
     * Count of warnings.
26
     * @var int
27
     */
28
    public $warningsCount;
29
    
30
    /**
31
     * @var \Plasma\Drivers\MySQL\ProtocolParser
32
     */
33
    protected $parser;
34
    
35
    /**
36
     * Constructor.
37
     * @param \Plasma\Drivers\MySQL\ProtocolParser  $parser
38
     */
39
    function __construct(\Plasma\Drivers\MySQL\ProtocolParser $parser) {
40
        $this->parser = $parser;
41
    }
42
    
43
    /**
44
     * Get the identifier for the packet.
45
     * @return string
46
     */
47 1
    static function getID(): string {
48 1
        return "\xFE";
49
    }
50
    
51
    /**
52
     * Parses the message, once the complete string has been received.
53
     * Returns false if not enough data has been received, or the remaining buffer.
54
     * @param string  $buffer
55
     * @return string|bool
56
     * @throws \Plasma\Drivers\MySQL\Messages\ParseException
57
     */
58
    function parseMessage(string $buffer) {
59
        $handshake = $this->parser->getHandshakeMessage();
60
        if(!$handshake) {
61
            throw new \Plasma\Drivers\MySQL\Messages\ParseException('No handshake message when receiving ok response packet');
62
        }
63
        
64
        $this->statusFlags = \Plasma\Drivers\MySQL\Messages\MessageUtility::readInt2($buffer);
65
        $this->warningsCount = \Plasma\Drivers\MySQL\Messages\MessageUtility::readInt2($buffer);
66
        
67
        return $buffer;
68
    }
69
    
70
    /**
71
     * Get the parser which created this message.
72
     * @return \Plasma\Drivers\MySQL\ProtocolParser
73
     */
74
    function getParser(): \Plasma\Drivers\MySQL\ProtocolParser {
75
        return $this->parser;
76
    }
77
    
78
    /**
79
     * Sets the parser state, if necessary. If not, return `-1`.
80
     * @return int
81
     */
82
    function setParserState(): int {
83
        return \Plasma\Drivers\MySQL\ProtocolParser::STATE_OK;
84
    }
85
}
86