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 ( 64caf3...9eb32a )
by Charlotte
06:50
created

AbstractColumnDefinition   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 140
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 140
ccs 30
cts 30
cp 1
rs 10
c 0
b 0
f 0
wmc 11

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getTableName() 0 2 1
A getFlags() 0 2 1
A getCharset() 0 2 1
A parseValue() 0 8 2
A __construct() 0 9 1
A getDecimals() 0 2 1
A getDatabaseName() 0 2 1
A getType() 0 2 1
A getName() 0 2 1
A getLength() 0 2 1
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 $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|null
38
     */
39
    protected $charset;
40
    
41
    /**
42
     * @var int|null
43
     */
44
    protected $length;
45
    
46
    /**
47
     * @var int
48
     */
49
    protected $flags;
50
    
51
    /**
52
     * @var int|null
53
     */
54
    protected $decimals;
55
    
56
    /**
57
     * Constructor.
58
     * @param string       $database
59
     * @param string       $table
60
     * @param string       $name
61
     * @param string       $type
62
     * @param string|null  $charset
63
     * @param int|null     $length
64
     * @param int          $flags
65
     * @param int|null     $decimals
66
     */
67 15
    function __construct(string $database, string $table, string $name, string $type, ?string $charset, ?int $length, int $flags, ?int $decimals) {
68 15
        $this->database = $database;
69 15
        $this->table = $table;
70 15
        $this->name = $name;
71 15
        $this->type = $type;
72 15
        $this->charset = $charset;
73 15
        $this->length = $length;
74 15
        $this->flags = $flags;
75 15
        $this->decimals = $decimals;
76 15
    }
77
    
78
    /**
79
     * Get the database name this column is in.
80
     * @return string
81
     */
82 1
    function getDatabaseName(): string {
83 1
        return $this->database;
84
    }
85
    
86
    /**
87
     * Get the table name this column is in.
88
     * @return string
89
     */
90 1
    function getTableName(): string {
91 1
        return $this->table;
92
    }
93
    
94
    /**
95
     * Get the column name.
96
     * @return string
97
     */
98 1
    function getName(): string {
99 1
        return $this->name;
100
    }
101
    
102
    /**
103
     * Get the type name, such as `BIGINT`, `VARCHAR`, etc.
104
     * @return string
105
     */
106 1
    function getType(): string {
107 1
        return $this->type;
108
    }
109
    
110
    /**
111
     * Get the charset, such as `utf8mb4`.
112
     * @return string|null
113
     */
114 1
    function getCharset(): ?string {
115 1
        return $this->charset;
116
    }
117
    
118
    /**
119
     * Get the maximum field length, if any.
120
     * @return int|null
121
     */
122 1
    function getLength(): ?int {
123 1
        return $this->length;
124
    }
125
    
126
    /**
127
     * Get the column flags.
128
     * @return int
129
     */
130 1
    function getFlags(): int {
131 1
        return $this->flags;
132
    }
133
    
134
    /**
135
     * Get the maximum shown decimal digits.
136
     * @return int|null
137
     */
138 1
    function getDecimals(): ?int {
139 1
        return $this->decimals;
140
    }
141
    
142
    /**
143
     * Parses the row value into the field type.
144
     * @param mixed  $value
145
     * @return mixed
146
     */
147 2
    function parseValue($value) {
148
        try {
149 2
            return \Plasma\Types\TypeExtensionsManager::getManager()->decodeType($this->type, $value)->getValue();
150 1
        } catch (\Plasma\Exception $e) {
151
            /* Continue regardless of error */
152
        }
153
        
154 1
        return $value;
155
    }
156
}
157