Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| SQLiteField | |
0.00% |
0 / 10 |
|
0.00% |
0 / 6 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| name | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| tableName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| defaultValue | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| isNullable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| type | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Wikimedia\Rdbms; |
| 4 | |
| 5 | use stdClass; |
| 6 | |
| 7 | class SQLiteField implements Field { |
| 8 | private stdClass $info; |
| 9 | private string $tableName; |
| 10 | |
| 11 | public function __construct( stdClass $info, string $tableName ) { |
| 12 | $this->info = $info; |
| 13 | $this->tableName = $tableName; |
| 14 | } |
| 15 | |
| 16 | /** @inheritDoc */ |
| 17 | public function name() { |
| 18 | return $this->info->name; |
| 19 | } |
| 20 | |
| 21 | /** @inheritDoc */ |
| 22 | public function tableName() { |
| 23 | return $this->tableName; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @return string |
| 28 | */ |
| 29 | public function defaultValue() { |
| 30 | if ( is_string( $this->info->dflt_value ) ) { |
| 31 | // Typically quoted |
| 32 | if ( preg_match( '/^\'(.*)\'$/', $this->info->dflt_value, $matches ) ) { |
| 33 | return str_replace( "''", "'", $matches[1] ); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | return $this->info->dflt_value; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @return bool |
| 42 | */ |
| 43 | public function isNullable() { |
| 44 | return !$this->info->notnull; |
| 45 | } |
| 46 | |
| 47 | /** @inheritDoc */ |
| 48 | public function type() { |
| 49 | return $this->info->type; |
| 50 | } |
| 51 | } |