Guess a column's formatter based on its type.

@param  Column $column
@param  string $tableName
@return \Closure|null

@throws \InvalidArgumentException
8712
public function guessFormat(Column $column, $tableName)
    {
        switch ($column->getType()->getName()) {
            case 'smallint':
                return function () {
                    return mt_rand(0, 65535);
                };
            case 'integer':
                return function () {
                    return mt_rand(0, intval('2147483647'));
                };
            case 'bigint':
                return function () {
                    return mt_rand(0, intval('18446744073709551615'));
                };
            case 'float':
                return function () {
                    return mt_rand(0, intval('4294967295')) / mt_rand(1, intval('4294967295'));
                };
            case 'decimal':
                $maxDigits = $column->getPrecision();
                $maxDecimalDigits = $column->getScale();

                $max = 10 ** ($maxDigits - $maxDecimalDigits);

                return function () use ($maxDecimalDigits, $max) {
                    $value = $this->generator->randomFloat($maxDecimalDigits, 0, $max);

                    // Prevents "Numeric value out of range" exceptions.
                    if ($value == $max) {
                        return $max - (1 / $maxDecimalDigits);
                    }

                    return $value;
                };
            case 'string':
                $size = $column->getLength() ?: 60;

                // If Faker's text() $maxNbChars argument is greater than 99,
                // the text it generates can have new lines which are ignored by non-textarea inputs
                // and break WebDriver tests, so we'll limit the size to 99.
                if ($size > 99) {
                    $size = 99;
                }

                return function () use ($size, $column, $tableName) {
                    if ($size >= 5) {
                        return $this->generator->text($size);
                    }

                    $columnName = "$tableName.{$column->getName()}";

                    throw new \InvalidArgumentException(
                        "$columnName is a string shorter than 5 characters,"
                        . " but Faker's text() can only generate text of at least 5 characters." . PHP_EOL
                        . "Please specify a more accurate formatter for $columnName."
                    );

                    // Of course we could just use str_random($size) here,
                    // but for the CHAR columns for which I got this error
                    // I found that it was better to specify a more precise formatter anyway,
                    // e.g. $faker->countryCode for sender_country.
                };
            case 'text':
                return function () {
                    return $this->generator->text;
                };
            case 'guid':
                return function () {
                    return $this->generator->uuid;
                };
            case 'date':
            case 'datetime':
            case 'datetimetz':
                return function () {
                    return $this->generator->datetime;
                };
            case 'time':
                return function () {
                    return $this->generator->time;
                };
            case 'boolean':
                return function () {
                    return $this->generator->boolean;
                };
                // Sadly Doctrine maps all TINYINT to BooleanType.
            case 'json':
            case 'json_array':
                return function () {
                    return json_encode([$this->generator->word => $this->generator->word]);
                };
            default:
                // No smart way to guess what the user expects here.
                return null;
        }
    }
1247362
public function hasColumn($table, $column)
    {
        $column = strtolower($column);

        return in_array($column, array_map('strtolower', $this->getColumnListing($table)));
    }
81241
protected function getCreateColumnCommentSQLQuery(Column $column, $table)
    {
        return 'COMMENT ON COLUMN '.$table.'.'.$column->getName().' IS '.$this->getColumnCommentSQLDeclaration($column);
    }
289790
public function addColumn($column)
    {
        if (is_string($column) && class_exists($column)) {
            $column = new $column();
        }

        if (!$column instanceof Column) {
            throw new \InvalidArgumentException(__METHOD__ . ' argument 1 need Column instance.');
        }

        $this->columns[$column->getName()] = $column;

        return $column;
    }
649080
public void showColumn(Object columnName) {
		for (TableColumn column : allColumns) {
			if (column.getHeaderValue().equals(columnName)) {
				showColumn(column);
				break;
			}
		}
	}
1121135
public function dropColumn($table, $columnName)
    {
        $table = $this->prefixTable($table);

        return $this->container->make('Piwik\Updater\Migration\Db\DropColumn', array(
            'table' => $table, 'columnName' => $columnName
        ));
    }
53982
protected function getAlterTableRenameColumnClause($oldColumnName, Column $column)
    {
        $oldColumnName = new Identifier($oldColumnName);

        return 'RENAME ' . $oldColumnName->getQuotedName($this) . ' TO ' . $column->getQuotedName($this);
    }
383780
public function columns($columnName, $label = null)
    {
        if (!is_string($columnName)) {
            throw new \InvalidArgumentException('$columnName must be set');
        }

        if ($this->resetColumns) {
            $this->columns = [];
            $this->resetColumns = false;
        }
        if (is_null($label)) {
            $label = $columnName;
        }
        $this->columns[$columnName] = $label;
        return $this;
    }
1358276
public function findColumn(string $name)
    {
        if (!is_string($name)) {
            throw InvalidArgumentException::format('Column name must be string, %s given', gettype($name));
        }

        return isset($this->columns[$name]) ? $this->columns[$name] : null;
    }
863859
public function getColumnNameWithPrefix($columName)
    {
        if (!isset($this->columnNamesWithPrefix[$columName])) {
            return null;
        }

        return $this->columnNamesWithPrefix[$columName];
    }
783701
protected function _parseColumn(Column\ColumnInterface $column)
    {
        $method = static::$_columnMethods[get_class($column)];
        return call_user_func_array([$this, $method], array($column));
    }
699523
public function describeColumn($tableName, $column) {
		
		// search in cached table structure
		if (isset($this->definitions[$tableName]['describe'])) {
			foreach ($this->definitions[$tableName]['describe'] as $d) {
				if ($column == $d->Field) {
					return $d;
				}
			}
		}
		
		$res = self::load('DESCRIBE `' . $tableName . '` `' . $column . '`', NULL, PAIR_DB_OBJECT);
		
		return ($res ? $res : NULL);
		
	}
231425
public function isCustomColumn($columnName)
    {
        $columnName = str_replace('.', '_', $columnName);
        $methodName = camel_case('laratables_custom_'.$columnName);

        if (method_exists($this->class, $methodName)) {
            return $methodName;
        }

        return false;
    }
380324
protected function tableMaybeInvalid($tableName) : string
    {
        if (!is_string($tableName)) {
            throw new \InvalidArgumentException(
                'Invalid table name type. Table name must be as string',
                E_USER_ERROR
            );
        }

        $tableName = trim($tableName);
        if ($tableName == '') {
            throw new \InvalidArgumentException(
                'Invalid parameter table name. Table name could not be empty.',
                E_USER_ERROR
            );
        }

        return $tableName;
    }
913989
public function getValidator(Column $column)
    {
        $key = $column->getName();
        if (!isset($this->validators[$key])) {
            $this->validators[$key] = new Validator();
            $this->validators[$key]->setColumn($column);
        }

        return $this->validators[$key];
    }
310899
public function findIdColumn($id, $column) {
		if (!empty($column)) $this->driver->field($column);
		$tableAlias = $this->driver->alias?$this->driver->alias.'.':'';
		return $this->driver->where($tableAlias.$this->id.'=?', [$id])
            ->fetchColumn();
	}
512297
protected function tableColumn($column)
    {
        if (is_null($this->table)) {
            $this->setTable();
        }

        return new Column($this->context, $this->table, $column);
    }