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.

AuthSwitchResponseCommand   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 102
ccs 0
cts 30
cp 0
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A resetSequence() 0 2 1
A onError() 0 3 1
A __construct() 0 4 1
A waitForCompletion() 0 2 1
A hasFinished() 0 2 1
A onComplete() 0 3 1
A getEncodedMessage() 0 3 1
A onNext() 0 1 1
A setParserState() 0 2 1
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\Commands;
11
12
/**
13
 * Auth Switch Response command.
14
 * @internal
15
 */
16
class AuthSwitchResponseCommand implements CommandInterface {
17
    use \Evenement\EventEmitterTrait;
18
    
19
    /**
20
     * @var \Plasma\Drivers\MySQL\Messages\AuthSwitchRequestMessage
21
     */
22
    protected $message;
23
    
24
    /**
25
     * @var \Plasma\Drivers\MySQL\AuthPlugins\AuthPluginInterface
26
     */
27
    protected $plugin;
28
    
29
    /**
30
     * @var string
31
     */
32
    protected $password;
33
    
34
    /**
35
     * @var bool
36
     */
37
    protected $finished = false;
38
    
39
    /**
40
     * Constructor.
41
     * @param \Plasma\Drivers\MySQL\Messages\AuthSwitchRequestMessage  $message
42
     * @param \Plasma\Drivers\MySQL\AuthPlugins\AuthPluginInterface    $plugin
43
     * @param string                                                   $password
44
     */
45
    function __construct(\Plasma\Drivers\MySQL\Messages\AuthSwitchRequestMessage $message, \Plasma\Drivers\MySQL\AuthPlugins\AuthPluginInterface $plugin, string $password) {
46
        $this->message = $message;
47
        $this->plugin = $plugin;
48
        $this->password = $password;
49
    }
50
    
51
    /**
52
     * Get the encoded message for writing to the database connection.
53
     * @return string
54
     */
55
    function getEncodedMessage(): string {
56
        $this->finished = true;
57
        return $this->plugin->getHandshakeAuth($this->password);
58
    }
59
    
60
    /**
61
     * Sets the parser state, if necessary. If not, return `-1`.
62
     * @return int
63
     */
64
    function setParserState(): int {
65
        return \Plasma\Drivers\MySQL\ProtocolParser::STATE_AUTH_SENT;
66
    }
67
    
68
    /**
69
     * Sets the command as completed. This state gets reported back to the user.
70
     * @return void
71
     */
72
    function onComplete(): void {
73
        $this->finished = true;
74
        $this->emit('end');
75
    }
76
    
77
    /**
78
     * Sets the command as errored. This state gets reported back to the user.
79
     * @param \Throwable  $throwable
80
     * @return void
81
     */
82
    function onError(\Throwable $throwable): void {
83
        $this->finished = true;
84
        $this->emit('error', array($throwable));
85
    }
86
    
87
    /**
88
     * Sends the next received value into the command.
89
     * @param mixed  $value
90
     * @return void
91
     */
92
    function onNext($value): void {
93
        // Nothing to do
94
    }
95
    
96
    /**
97
     * Whether the command has finished.
98
     * @return bool
99
     */
100
    function hasFinished(): bool {
101
        return $this->finished;
102
    }
103
    
104
    /**
105
     * Whether this command sets the connection as busy.
106
     * @return bool
107
     */
108
    function waitForCompletion(): bool {
109
        return true;
110
    }
111
    
112
    /**
113
     * Whether the sequence ID should be resetted.
114
     * @return bool
115
     */
116
    function resetSequence(): bool {
117
        return false;
118
    }
119
}
120