Debian Codegraph @

includes/libs/rdbms/field/SQLiteField.php

raw symbols SCIP
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 public function name() {
17 return $this->info->name;
18 }
19
20 public function tableName() {
21 return $this->tableName;
22 }
23
24 public function defaultValue() {
25 if ( is_string( $this->info->dflt_value ) ) {
26 // Typically quoted
27 if ( preg_match( '/^\'(.*)\'$/', $this->info->dflt_value, $matches ) ) {
28 return str_replace( "''", "'", $matches[1] );
29 }
30 }
31
32 return $this->info->dflt_value;
33 }
34
35 /**
36 * @return bool
37 */
38 public function isNullable() {
39 return !$this->info->notnull;
40 }
41
42 public function type() {
43 return $this->info->type;
44 }
45 }