for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace KitLoong\MigrationsGenerator\Schema\MySQL;
use Illuminate\Support\Collection;
use stdClass;
/**
* Class ShowColumn
*
* Entity from MySQL SHOW COLUMNS statement
* @see https://dev.mysql.com/doc/refman/5.7/en/show-columns.html
* @see https://dev.mysql.com/doc/refman/8.0/en/show-columns.html
* @package KitLoong\MigrationsGenerator\Schema\MySQL
*/
class ShowColumn
{
/** @var string */
private $field;
private $type;
private $null;
private $key;
/** @var string|null */
private $default;
private $extra;
public function __construct(stdClass $column)
// Convert column property to case insensitive
// Issue https://github.com/kitloong/laravel-migrations-generator/issues/34
$lowerKey = (new Collection($column))->mapWithKeys(function ($item, $key) {
return [strtolower($key) => $item];
});
$this->field = $lowerKey['field'];
$this->type = $lowerKey['type'];
$this->null = $lowerKey['null'];
$this->key = $lowerKey['key'];
$this->default = $lowerKey['default'];
$this->extra = $lowerKey['extra'];
}
* @return string
public function getField(): string
return $this->field;
public function getType(): string
return $this->type;
public function getNull(): string
return $this->null;
public function getKey(): string
return $this->key;
* @return string|null
public function getDefault(): ?string
return $this->default;
public function getExtra(): string
return $this->extra;