type === 'datetime' && ! $this->isNull && $default === null && $insertMode ) { $this->default = date('Y-m-d H:i:s'); } else { $this->default = $default; } $this->md5 = md5($this->field); $this->trueType = preg_replace('@(\(.*)|(\s/.*)@s', '', $this->type); // length is unknown for geometry fields, // make enough space to edit very simple WKTs if ($columnLength === -1) { $columnLength = 30; } $this->length = preg_match('@float|double@', $this->type) === 1 ? 100 : $columnLength; /** * TODO: This property is useless at the moment. * It seems like a long time ago before refactoring into classes, * this kept track of how many timestamps are in the table. */ $this->firstTimestamp = $this->trueType === 'timestamp'; } public function getFractionalSecondsPrecision(): int { if ($this->trueType !== 'timestamp' && $this->trueType !== 'datetime' && $this->trueType !== 'time') { return 0; } $matches = []; if (preg_match('@\((\d+)\)@', $this->type, $matches) === 1) { return (int) $matches[1]; } return 0; } public function getDisplayType(): string { // Enum and set values, and any additional options within comments, are not displayed return match ($this->trueType) { 'set', 'enum' => $this->trueType, default => preg_replace('@\s/.+@', '', $this->type), }; } }