src/renderers/ColumnRenderer.php
/**
     * Builds general methods chain for column definition.
     * @param ColumnInterface $column
     * @param PrimaryKeyInterface|null $primaryKey
     * @param string|null $schema
     */
Builds general methods chain for column definition.
@param ColumnInterface $column
@param PrimaryKeyInterface|null $primaryKey
@param string|null $schema
Builds general methods chain for column definition . @param ColumnInterface $column @param PrimaryKeyInterface|null $primaryKey @param string|null $schema
private function buildGeneralDefinition(
        ColumnInterface $column,
        ?PrimaryKeyInterface $primaryKey,
        string $schema = null
    ): void {
        array_unshift($this->definition, '$this');
        if ($this->isUnsignedPossible && $column->isUnsigned()) {
            $this->definition[] = 'unsigned()';
        }
        if ($this->isNotNullPossible && $column->isNotNull()) {
            $this->definition[] = 'notNull()';
        }
        $default = $column->getDefault();
        if ($default !== null) {
            if ($default instanceof Expression) {
                $this->definition[] = "defaultExpression('{$this->escapeQuotes($default->expression)}')";
            } elseif (is_array($default)) {
                $this->definition[] = "defaultValue('{$this->escapeQuotes(Json::encode($default))}')";
            } else {
                $this->definition[] = "defaultValue('{$this->escapeQuotes((string)$default)}')";
            }
        }
        $columnAppend = $column->getAppend();
        if (
            $this->isPrimaryKeyPossible
            && $primaryKey
            && $primaryKey->isComposite() === false
            && $column->isColumnInPrimaryKey($primaryKey)
        ) {
            $schemaAppend = $column->prepareSchemaAppend(true, $column->isAutoIncrement(), $schema);
            if ($schemaAppend !== null) {
                if (!empty($columnAppend)) {
                    $schemaAppend .= ' ' . trim(str_replace($schemaAppend, '', $columnAppend));
                }
                $schemaAppend = trim($schemaAppend);
            }
            $this->definition[] = "append('" . $this->escapeQuotes($schemaAppend) . "')";
        } elseif (!empty($columnAppend)) {
            $this->definition[] = "append('" . $this->escapeQuotes(trim($columnAppend)) . "')";
        }
        $comment = $column->getComment();
        if ($comment) {
            $this->definition[] = "comment('" . $this->escapeQuotes((string)$comment) . "')";
        }
        $after = $column->getAfter();
        if ($after) {
            $this->definition[] = "after('" . $this->escapeQuotes($after) . "')";
        } elseif ($column->isFirst()) {
            $this->definition[] = 'first()';
        }
    }
private function buildGeneralDefinition ( ColumnInterface $ column , ? PrimaryKeyInterface $ primaryKey , string $ schema = null ) : void { array_unshift ( $ this -> definition , '$this' ) ; if ( $ this -> isUnsignedPossible && $ column -> isUnsigned ( ) ) { $ this -> definition [ ] = 'unsigned()' ; } if ( $ this -> isNotNullPossible && $ column -> isNotNull ( ) ) { $ this -> definition [ ] = 'notNull()' ; } $ default = $ column -> getDefault ( ) ; if ( $ default !== null ) { if ( $ default instanceof Expression ) { $ this -> definition [ ] = " defaultExpression(' { $ this -> escapeQuotes ( $ default -> expression ) } ') " ; } elseif ( is_array ( $ default ) ) { $ this -> definition [ ] = " defaultValue(' { $ this -> escapeQuotes ( Json :: encode ( $ default ) ) } ') " ; } else { $ this -> definition [ ] = " defaultValue(' { $ this -> escapeQuotes ( ( string ) $ default ) } ') " ; } } $ columnAppend = $ column -> getAppend ( ) ; if ( $ this -> isPrimaryKeyPossible && $ primaryKey && $ primaryKey -> isComposite ( ) === false && $ column -> isColumnInPrimaryKey ( $ primaryKey ) ) { $ schemaAppend = $ column -> prepareSchemaAppend ( true , $ column -> isAutoIncrement ( ) , $ schema ) ; if ( $ schemaAppend !== null ) { if ( ! empty ( $ columnAppend ) ) { $ schemaAppend .= ' ' . trim ( str_replace ( $ schemaAppend , '' , $ columnAppend ) ) ; } $ schemaAppend = trim ( $ schemaAppend ) ; } $ this -> definition [ ] = " append(' " . $ this -> escapeQuotes ( $ schemaAppend ) . " ') " ; } elseif ( ! empty ( $ columnAppend ) ) { $ this -> definition [ ] = " append(' " . $ this -> escapeQuotes ( trim ( $ columnAppend ) ) . " ') " ; } $ comment = $ column -> getComment ( ) ; if ( $ comment ) { $ this -> definition [ ] = " comment(' " . $ this -> escapeQuotes ( ( string ) $ comment ) . " ') " ; } $ after = $ column -> getAfter ( ) ; if ( $ after ) { $ this -> definition [ ] = " after(' " . $ this -> escapeQuotes ( $ after ) . " ') " ; } elseif ( $ column -> isFirst ( ) ) { $ this -> definition [ ] = 'first()' ; } }
Builds general methods chain for column definition.
Builds general methods chain for column definition .