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 ( d13c9c...463153 )
by Charlotte
03:30
created

QueryCommand   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 88
ccs 18
cts 24
cp 0.75
rs 10
c 0
b 0
f 0
wmc 11

5 Methods

Rating   Name   Duplication   Size   Complexity  
A createResolve() 0 3 1
A __construct() 0 5 1
A resetSequence() 0 2 1
A getEncodedMessage() 0 2 1
B onNext() 0 11 7
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\Commands;
11
12
/**
13
 * Query command.
14
 * @internal
15
 */
16
class QueryCommand extends PromiseCommand {
17
    /**
18
     * The identifier for this command.
19
     * @var int
20
     * @source
21
     */
22
    const COMMAND_ID = 0x03;
23
    
24
    /**
25
     * @var \Plasma\DriverInterface
26
     */
27
    protected $driver;
28
    
29
    /**
30
     * @var string
31
     */
32
    protected $query;
33
    
34
    /**
35
     * @var \Plasma\ColumnDefinitionInterface[]
36
     */
37
    protected $fields = array();
38
    
39
    /**
40
     * @var int|null
41
     */
42
    protected $fieldsCount;
43
    
44
    /**
45
     * @var \Plasma\StreamQueryResult|\Plasma\QueryResult|null
46
     */
47
    protected $resolveValue;
48
    
49
    /**
50
     * Constructor.
51
     * @param \Plasma\DriverInterface  $driver
52
     * @param string                   $query
53
     */
54 2
    function __construct(\Plasma\DriverInterface $driver, string $query) {
55 2
        parent::__construct();
56
        
57 2
        $this->driver = $driver;
58 2
        $this->query = $query;
59 2
    }
60
    
61
    /**
62
     * Get the encoded message for writing to the database connection.
63
     * @return string
64
     */
65 2
    function getEncodedMessage(): string {
66 2
        return \chr(static::COMMAND_ID).$this->query;
67
    }
68
    
69
    /**
70
     * Sends the next received value into the command.
71
     * @param mixed  $value
72
     * @return void
73
     */
74 2
    function onNext($value): void {
75 2
        if($value instanceof \Plasma\Drivers\MySQL\ProtocolOnNextCaller) {
76 1
            $this->handleQueryOnNextCaller($value);
77 2
        } elseif($value instanceof \Plasma\Drivers\MySQL\Messages\OkResponseMessage || $value instanceof \Plasma\Drivers\MySQL\Messages\EOFMessage) {
78 2
            if($this->resolveValue !== null) {
79
                $value->getParser()->markCommandAsFinished($this);
80 2
            } elseif(empty($this->fields) && $value instanceof \Plasma\Drivers\MySQL\Messages\OkResponseMessage) {
81 2
                $this->resolveValue = new \Plasma\QueryResult($value->affectedRows, $value->warningsCount, $value->lastInsertedID);
82 2
                $value->getParser()->markCommandAsFinished($this);
83
            } else {
84
                $this->createResolve();
85
            }
86
        }
87 2
    }
88
    
89
    /**
90
     * Creates the resolve value and resolves the promise.
91
     * @return void
92
     */
93
    function createResolve(): void {
94
        $this->resolveValue = new \Plasma\StreamQueryResult($this->driver, $this, 0, 0, $this->fields, null);
95
        $this->deferred->resolve($this->resolveValue);
96
    }
97
    
98
    /**
99
     * Whether the sequence ID should be resetted.
100
     * @return bool
101
     */
102 2
    function resetSequence(): bool {
103 2
        return true;
104
    }
105
}
106