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.
Passed
Push — master ( 6078a4...f68c38 )
by Charlotte
02:21
created

TextProtocolValues::decode()   C

Complexity

Conditions 15
Paths 12

Size

Total Lines 30
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 81.6765

Importance

Changes 0
Metric Value
cc 15
eloc 22
nc 12
nop 2
dl 0
loc 30
ccs 5
cts 15
cp 0.3333
crap 81.6765
rs 5.9166
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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;
11
12
/**
13
 * Text protocol rowset values decoder.
14
 * @internal
15
 */
16
class TextProtocolValues {
17
    /**
18
     * Standard decode value, if type extensions failed.
19
     * @param \Plasma\ColumnDefinitionInterface  $column
20
     * @param string|null                        $param
21
     * @return mixed
22
     * @throws \Plasma\Exception
23
     */
24 3
    static function decode(\Plasma\ColumnDefinitionInterface $column, $param) {
25 3
        $flags = $column->getFlags();
26
        
27 3
        if($param !== null && ($flags & \Plasma\Drivers\MySQL\FieldFlags::ZEROFILL_FLAG) === 0) {
28 3
            switch($column->getType()) {
29
                case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_LONG:
30
                    if(($flags & \Plasma\Drivers\MySQL\FieldFlags::UNSIGNED_FLAG) === 0 || \PHP_INT_SIZE > 4) {
31
                        $param = (int) $param;
32
                    }
33
                break;
34
                case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_LONGLONG:
35
                    if(($flags & \Plasma\Drivers\MySQL\FieldFlags::UNSIGNED_FLAG) === 0 && \PHP_INT_SIZE > 4) {
36
                        $param = (int) $param;
37
                    }
38
                break;
39
                case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_TINY:
40
                case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_SHORT:
41
                case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_INT24:
42
                case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_TIMESTAMP:
43
                    $param = (int) $param;
44
                break;
45
                case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_FLOAT:
46
                case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_DOUBLE:
47
                    $param = (float) $param;
48
                break;
49
                // Other types are taken as string
50
            }
51
        }
52
        
53 3
        return $param;
54
    }
55
}
56