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