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
Push — master ( bf6976...0e8096 )
by Charlotte
03:40
created

AuthSecureConnection::receiveMoreData()   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 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\AuthPlugins;
11
12
/**
13
 * Defines the interface for auth plugins.
14
 * @internal
15
 */
16
class AuthSecureConnection implements AuthPluginInterface {
17
    /**
18
     * @var \Plasma\Drivers\MySQL\ProtocolParser
19
     */
20
    protected $parser;
21
    
22
    /**
23
     * @var \Plasma\Drivers\MySQL\Messages\HandshakeMessage
24
     */
25
    protected $handshake;
26
    
27
    /**
28
     * Constructor. Receives the protocol parser and the handshake message.
29
     * @param \Plasma\Drivers\MySQL\ProtocolParser             $parser
30
     * @param \Plasma\Drivers\MySQL\Messages\HandshakeMessage  $handshake
31
     */
32 15
    function __construct(\Plasma\Drivers\MySQL\ProtocolParser $parser, \Plasma\Drivers\MySQL\Messages\HandshakeMessage $handshake) {
33 15
        $this->parser = $parser;
34 15
        $this->handshake = $handshake;
35 15
    }
36
37
    /**
38
     * Computes the auth response, including the length, for the handshake response.
39
     * @param string  $password
40
     * @return string
41
     */
42 14
    function getHandshakeAuth(string $password): string {
43 14
        if($password !== '') {
44 2
            $hash = \sha1($password, true);
45 2
            $str = $hash ^ \sha1($this->handshake->scramble.\sha1($hash, true), true);
46
            
47 2
            return \Plasma\BinaryBuffer::writeStringLength($str);
48
        }
49
        
50 12
        return "\x00";
51
    }
52
    
53
    /**
54
     * We received more auth data, so we send it into the auth plugin.
55
     * @param \Plasma\Drivers\MySQL\Messages\AuthMoreDataMessage  $message
56
     * @return \Plasma\Drivers\MySQL\Commands\CommandInterface
57
     * @throws \Plasma\Exception
58
     */
59 1
    function receiveMoreData(\Plasma\Drivers\MySQL\Messages\AuthMoreDataMessage $message): \Plasma\Drivers\MySQL\Commands\CommandInterface {
60 1
        throw new \Plasma\Exception('Auth plugin does not support auth more data');
61
    }
62
}
63