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