Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 13 |
CRAP | |
0.00% |
0 / 1 |
MySQLField | |
0.00% |
0 / 27 |
|
0.00% |
0 / 13 |
240 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
12 | |||
name | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
tableName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
type | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isNullable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
defaultValue | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isKey | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isMultipleKey | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isBinary | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isNumeric | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isBlob | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isUnsigned | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isZerofill | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Wikimedia\Rdbms; |
4 | |
5 | class MySQLField implements Field { |
6 | private string $name; |
7 | private string $tablename; |
8 | private $default; |
9 | private $max_length; |
10 | private bool $nullable; |
11 | private bool $is_pk; |
12 | private bool $is_unique; |
13 | private bool $is_multiple; |
14 | private bool $is_key; |
15 | private string $type; |
16 | private bool $binary; |
17 | private bool $is_numeric; |
18 | private bool $is_blob; |
19 | private bool $is_unsigned; |
20 | private bool $is_zerofill; |
21 | |
22 | public function __construct( $info ) { |
23 | $this->name = $info->name; |
24 | $this->tablename = $info->table; |
25 | $this->default = $info->def; |
26 | $this->max_length = $info->max_length; |
27 | $this->nullable = !$info->not_null; |
28 | $this->is_pk = $info->primary_key; |
29 | $this->is_unique = $info->unique_key; |
30 | $this->is_multiple = $info->multiple_key; |
31 | $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple ); |
32 | $this->type = $info->type; |
33 | $this->binary = $info->binary ?? false; |
34 | $this->is_numeric = $info->numeric ?? false; |
35 | $this->is_blob = $info->blob ?? false; |
36 | $this->is_unsigned = $info->unsigned ?? false; |
37 | $this->is_zerofill = $info->zerofill ?? false; |
38 | } |
39 | |
40 | /** |
41 | * @return string |
42 | */ |
43 | public function name() { |
44 | return $this->name; |
45 | } |
46 | |
47 | /** |
48 | * @return string |
49 | */ |
50 | public function tableName() { |
51 | return $this->tablename; |
52 | } |
53 | |
54 | /** |
55 | * @return string |
56 | */ |
57 | public function type() { |
58 | return $this->type; |
59 | } |
60 | |
61 | /** |
62 | * @return bool |
63 | */ |
64 | public function isNullable() { |
65 | return $this->nullable; |
66 | } |
67 | |
68 | public function defaultValue() { |
69 | return $this->default; |
70 | } |
71 | |
72 | /** |
73 | * @return bool |
74 | */ |
75 | public function isKey() { |
76 | return $this->is_key; |
77 | } |
78 | |
79 | /** |
80 | * @return bool |
81 | */ |
82 | public function isMultipleKey() { |
83 | return $this->is_multiple; |
84 | } |
85 | |
86 | /** |
87 | * @return bool |
88 | */ |
89 | public function isBinary() { |
90 | return $this->binary; |
91 | } |
92 | |
93 | /** |
94 | * @return bool |
95 | */ |
96 | public function isNumeric() { |
97 | return $this->is_numeric; |
98 | } |
99 | |
100 | /** |
101 | * @return bool |
102 | */ |
103 | public function isBlob() { |
104 | return $this->is_blob; |
105 | } |
106 | |
107 | /** |
108 | * @return bool |
109 | */ |
110 | public function isUnsigned() { |
111 | return $this->is_unsigned; |
112 | } |
113 | |
114 | /** |
115 | * @return bool |
116 | */ |
117 | public function isZerofill() { |
118 | return $this->is_zerofill; |
119 | } |
120 | } |