Final Class Yiisoft\Db\Pgsql\Column\ColumnDefinitionParser
| Inheritance | Yiisoft\ |
|---|
Parses column definition string. For example, string(255) or int unsigned.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| parse() | Yiisoft\ |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| TYPE_PATTERN | '/^(?:(' . 'time(?:stamp)?\ |
Yiisoft\ |
Method Details
| public array parse ( string $definition ) | ||
| $definition | string | |
public function parse(string $definition): array
{
preg_match(self::TYPE_PATTERN, $definition, $matches);
/** @var string $type */
$type = $matches[3] ?? preg_replace('/\s*\(\d+\)/' , '', $matches[1]);
$type = strtolower($type);
$info = ['type' => $type];
$typeDetails = $matches[4] ?? $matches[2] ?? '';
if ($typeDetails !== '') {
if ($type === 'enum') {
$info += $this->enumInfo($typeDetails);
} else {
$info += $this->sizeInfo($typeDetails);
}
}
if (isset($matches[5])) {
/** @psalm-var positive-int */
$info['dimension'] = substr_count($matches[5], '[');
}
$extra = substr($definition, strlen($matches[0]));
return $info + $this->extraInfo($extra);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.