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
Pull Request — master (#15)
by Charlotte
02:14
created

AbstractColumnDefinition::getDecimals()   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 0
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 Core component
4
 * Copyright 2018-2019 PlasmaPHP, All Rights Reserved
5
 *
6
 * Website: https://github.com/PlasmaPHP
7
 * License: https://github.com/PlasmaPHP/core/blob/master/LICENSE
8
*/
9
10
namespace Plasma;
11
12
/**
13
 * Column Definitions define columns (who would've thought of that?). Such as their name, type, length, etc.
14
 */
15
abstract class AbstractColumnDefinition implements ColumnDefinitionInterface {
16
    /**
17
     * @var string
18
     */
19
    protected $table;
20
    
21
    /**
22
     * @var string
23
     */
24
    protected $name;
25
    
26
    /**
27
     * @var string
28
     */
29
    protected $type;
30
    
31
    /**
32
     * @var string|null
33
     */
34
    protected $charset;
35
    
36
    /**
37
     * @var int|null
38
     */
39
    protected $length;
40
    
41
    /**
42
     * @var int
43
     */
44
    protected $flags;
45
    
46
    /**
47
     * @var int|null
48
     */
49
    protected $decimals;
50
    
51
    /**
52
     * Constructor.
53
     * @param string       $table
54
     * @param string       $name
55
     * @param string       $type
56
     * @param string|null  $charset
57
     * @param int|null     $length
58
     * @param int          $flags
59
     * @param int|null     $decimals
60
     */
61 14
    function __construct(string $table, string $name, string $type, ?string $charset, ?int $length, int $flags, ?int $decimals) {
62 14
        $this->table = $table;
63 14
        $this->name = $name;
64 14
        $this->type = $type;
65 14
        $this->charset = $charset;
66 14
        $this->length = $length;
67 14
        $this->flags = $flags;
68 14
        $this->decimals = $decimals;
69 14
    }
70
    
71
    /**
72
     * Get the table name this column is in.
73
     * @return string
74
     */
75 1
    function getTableName(): string {
76 1
        return $this->table;
77
    }
78
    
79
    /**
80
     * Get the column name.
81
     * @return string
82
     */
83 1
    function getName(): string {
84 1
        return $this->name;
85
    }
86
    
87
    /**
88
     * Get the type name, such as `BIGINT`, `VARCHAR`, etc.
89
     * @return string
90
     */
91 1
    function getType(): string {
92 1
        return $this->type;
93
    }
94
    
95
    /**
96
     * Get the charset, such as `utf8mb4`.
97
     * @return string|null
98
     */
99 1
    function getCharset(): ?string {
100 1
        return $this->charset;
101
    }
102
    
103
    /**
104
     * Get the maximum field length, if any.
105
     * @return int|null
106
     */
107 1
    function getLength(): ?int {
108 1
        return $this->length;
109
    }
110
    
111
    /**
112
     * Get the column flags.
113
     * @return int
114
     */
115 1
    function getFlags(): int {
116 1
        return $this->flags;
117
    }
118
    
119
    /**
120
     * Get the maximum shown decimal digits.
121
     * @return int|null
122
     */
123 1
    function getDecimals(): ?int {
124 1
        return $this->decimals;
125
    }
126
    
127
    /**
128
     * Parses the row value into the field type.
129
     * @param mixed  $value
130
     * @return mixed
131
     */
132 2
    function parseValue($value) {
133
        try {
134 2
            return \Plasma\Types\TypeExtensionsManager::getManager()->decodeType($this->type, $value)->getValue();
135 1
        } catch (\Plasma\Exception $e) {
136
            /* Continue regardless of error */
137
        }
138
        
139 1
        return $value;
140
    }
141
}
142