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 ( 04f32c...537cf3 )
by Charlotte
02:16
created

ColumnDefinition   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 155
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 155
ccs 33
cts 33
cp 1
rs 10
c 0
b 0
f 0
wmc 12

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getCharset() 0 2 1
A __construct() 0 10 1
A getDecimals() 0 2 1
A getType() 0 2 1
A getName() 0 2 1
A getLength() 0 2 1
A isNullable() 0 2 1
A parseValue() 0 8 2
A getFlags() 0 2 1
A getDatabaseName() 0 2 1
A getTableName() 0 2 1
1
<?php
2
/**
3
 * Plasma Core component
4
 * Copyright 2018 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
class ColumnDefinition implements ColumnDefinitionInterface {
16
    /**
17
     * @var string
18
     */
19
    protected $database;
20
    
21
    /**
22
     * @var string
23
     */
24
    protected $table;
25
    
26
    /**
27
     * @var string
28
     */
29
    protected $name;
30
    
31
    /**
32
     * @var string
33
     */
34
    protected $type;
35
    
36
    /**
37
     * @var string
38
     */
39
    protected $charset;
40
    
41
    /**
42
     * @var int|null
43
     */
44
    protected $length;
45
    
46
    /**
47
     * @var bool
48
     */
49
    protected $nullable;
50
    
51
    /**
52
     * @var int
53
     */
54
    protected $flags;
55
    
56
    /**
57
     * @var int|null
58
     */
59
    protected $decimals;
60
    
61
    /**
62
     * Constructor.
63
     * @param string    $database
64
     * @param string    $table
65
     * @param string    $name
66
     * @param string    $type
67
     * @param string    $charset
68
     * @param int|null  $length
69
     * @param bool      $nullable
70
     * @param int       $flags
71
     * @param int|null  $decimals
72
     */
73 11
    function __construct(string $database, string $table, string $name, string $type, string $charset, ?int $length, bool $nullable, int $flags, ?int $decimals) {
74 11
        $this->database = $database;
75 11
        $this->table = $table;
76 11
        $this->name = $name;
77 11
        $this->type = $type;
78 11
        $this->charset = $charset;
79 11
        $this->length = $length;
80 11
        $this->nullable = $nullable;
81 11
        $this->flags = $flags;
82 11
        $this->decimals = $decimals;
83 11
    }
84
    
85
    /**
86
     * Get the database name this column is in.
87
     * @return string
88
     */
89 1
    function getDatabaseName(): string {
90 1
        return $this->database;
91
    }
92
    
93
    /**
94
     * Get the table name this column is in.
95
     * @return string
96
     */
97 1
    function getTableName(): string {
98 1
        return $this->table;
99
    }
100
    
101
    /**
102
     * Get the column name.
103
     * @return string
104
     */
105 1
    function getName(): string {
106 1
        return $this->name;
107
    }
108
    
109
    /**
110
     * Get the type name, such as `BIGINT`, `VARCHAR`, etc.
111
     * @return string
112
     */
113 1
    function getType(): string {
114 1
        return $this->type;
115
    }
116
    
117
    /**
118
     * Get the charset, such as `utf8mb4`.
119
     * @return string
120
     */
121 1
    function getCharset(): string {
122 1
        return $this->charset;
123
    }
124
    
125
    /**
126
     * Get the maximum field length, if any.
127
     * @return int|null
128
     */
129 1
    function getLength(): ?int {
130 1
        return $this->length;
131
    }
132
    
133
    /**
134
     * Whether the column is nullable (not `NOT NULL`).
135
     * @return bool
136
     */
137 1
    function isNullable(): bool {
138 1
        return $this->nullable;
139
    }
140
    
141
    /**
142
     * Get the column flags.
143
     * @return int
144
     */
145 1
    function getFlags(): int {
146 1
        return $this->flags;
147
    }
148
    
149
    /**
150
     * Get the maximum shown decimal digits.
151
     * @return int|null
152
     */
153 1
    function getDecimals(): ?int {
154 1
        return $this->decimals;
155
    }
156
    
157
    /**
158
     * Parses the row value into the field type.
159
     * @param mixed  $value
160
     * @return mixed
161
     */
162 2
    function parseValue($value) {
163
        try {
164 2
            return \Plasma\Types\TypeExtensionsManager::getManager()->decodeType($this->type, $value);
165 2
        } catch (\Plasma\Exception $e) {
166
            /* Continue regardless of error */
167
        }
168
        
169 2
        return $value;
170
    }
171
}
172