@@ -70,17 +70,17 @@ |
||
| 70 | 70 | */ |
| 71 | 71 | public function register(): void |
| 72 | 72 | { |
| 73 | - $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
| 73 | + $this->app->bind(Configuration::class, function(ContainerInterface $app) { |
|
| 74 | 74 | /** @template T @var Config<T> $config */ |
| 75 | 75 | $config = $app->get(Config::class); |
| 76 | 76 | $driver = $config->get('database.default', 'default'); |
| 77 | 77 | |
| 78 | 78 | return new Configuration($config->get('database.connections.' . $driver, [])); |
| 79 | 79 | }); |
| 80 | - $this->app->share(Pool::class, function (ContainerInterface $app) { |
|
| 80 | + $this->app->share(Pool::class, function(ContainerInterface $app) { |
|
| 81 | 81 | return new Pool($app->get(Config::class)->get('database', [])); |
| 82 | 82 | }); |
| 83 | - $this->app->share(Connection::class, function (ContainerInterface $app) { |
|
| 83 | + $this->app->share(Connection::class, function(ContainerInterface $app) { |
|
| 84 | 84 | return new Connection( |
| 85 | 85 | $app->get(Configuration::class), |
| 86 | 86 | $app->get(LoggerInterface::class) |
@@ -157,13 +157,13 @@ |
||
| 157 | 157 | foreach ($results as $cfg) { |
| 158 | 158 | if ($cfg->parent) { |
| 159 | 159 | $results = $this->queryBuilder |
| 160 | - ->from($this->table) |
|
| 161 | - ->where('env')->is($cfg->env) |
|
| 162 | - ->where('module')->is($cfg->parent) |
|
| 163 | - ->where('status')->is(1) |
|
| 164 | - ->select() |
|
| 165 | - ->fetchObject() |
|
| 166 | - ->all(); |
|
| 160 | + ->from($this->table) |
|
| 161 | + ->where('env')->is($cfg->env) |
|
| 162 | + ->where('module')->is($cfg->parent) |
|
| 163 | + ->where('status')->is(1) |
|
| 164 | + ->select() |
|
| 165 | + ->fetchObject() |
|
| 166 | + ->all(); |
|
| 167 | 167 | |
| 168 | 168 | foreach ($results as $cfg) { |
| 169 | 169 | $config[$cfg->name] = $cfg->value ?? $cfg->default_value; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | protected function parse(string $env): array |
| 131 | 131 | { |
| 132 | - $environments = array_filter((array)preg_split('/(\/|\.)/', $env)); |
|
| 132 | + $environments = array_filter((array) preg_split('/(\/|\.)/', $env)); |
|
| 133 | 133 | array_unshift($environments, ''); |
| 134 | 134 | |
| 135 | 135 | return $environments; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $results = $this->queryBuilder |
| 185 | 185 | ->from($this->table) |
| 186 | - ->where('id')->in(function (SubQuery $q) use ($env, $group) { |
|
| 186 | + ->where('id')->in(function(SubQuery $q) use ($env, $group) { |
|
| 187 | 187 | $query = $q->from($this->table) |
| 188 | 188 | ->where('module')->is($group) |
| 189 | 189 | ->where('status')->is(1) |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | $query->where('env')->is($env); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - $query->select(function (ColumnExpression $cexp) { |
|
| 198 | - $cexp->column(function (Expression $exp) { |
|
| 197 | + $query->select(function(ColumnExpression $cexp) { |
|
| 198 | + $cexp->column(function(Expression $exp) { |
|
| 199 | 199 | $exp->op('COALESCE'); |
| 200 | 200 | }); |
| 201 | 201 | }); |
@@ -57,8 +57,7 @@ discard block |
||
| 57 | 57 | * class DatabaseConfigLoader |
| 58 | 58 | * @package Platine\Framework\Config |
| 59 | 59 | */ |
| 60 | -class DatabaseConfigLoader implements LoaderInterface |
|
| 61 | -{ |
|
| 60 | +class DatabaseConfigLoader implements LoaderInterface { |
|
| 62 | 61 | |
| 63 | 62 | /** |
| 64 | 63 | * The QueryBuilder instance |
@@ -179,8 +178,7 @@ discard block |
||
| 179 | 178 | * @param string|null $env |
| 180 | 179 | * @return mixed |
| 181 | 180 | */ |
| 182 | - public function getConfigurations(string $group, ?string $env = null) |
|
| 183 | - { |
|
| 181 | + public function getConfigurations(string $group, ?string $env = null) { |
|
| 184 | 182 | $results = $this->queryBuilder |
| 185 | 183 | ->from($this->table) |
| 186 | 184 | ->where('id')->in(function (SubQuery $q) use ($env, $group) { |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | ) { |
| 72 | 72 | parent::__construct($app, $repository, $config, $filesystem); |
| 73 | 73 | $this->setName('migration:migrate') |
| 74 | - ->setDescription('Upgrade migration to latest'); |
|
| 74 | + ->setDescription('Upgrade migration to latest'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | ) { |
| 72 | 72 | parent::__construct($app, $repository, $config, $filesystem); |
| 73 | 73 | $this->setName('migration:reset') |
| 74 | - ->setDescription('Rollback all migration done before'); |
|
| 74 | + ->setDescription('Rollback all migration done before'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | ) { |
| 81 | 81 | parent::__construct($app, $repository, $config, $filesystem); |
| 82 | 82 | $this->setName('migration:init') |
| 83 | - ->setDescription("Initialize the migration data. Note this command\n" |
|
| 84 | - . "is run only at the first time to create migration table"); |
|
| 83 | + ->setDescription("Initialize the migration data. Note this command\n" |
|
| 84 | + . "is run only at the first time to create migration table"); |
|
| 85 | 85 | |
| 86 | 86 | $this->schema = $schema; |
| 87 | 87 | } |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | $tableName = $this->table; |
| 120 | 120 | $this->schema->create($tableName, function (CreateTable $table) { |
| 121 | 121 | $table->string('version', 20) |
| 122 | - ->description('The migration version') |
|
| 123 | - ->primary(); |
|
| 122 | + ->description('The migration version') |
|
| 123 | + ->primary(); |
|
| 124 | 124 | $table->string('description') |
| 125 | - ->description('The migration description'); |
|
| 125 | + ->description('The migration description'); |
|
| 126 | 126 | $table->datetime('created_at') |
| 127 | 127 | ->description('Migration run time'); |
| 128 | 128 | |
@@ -117,7 +117,7 @@ |
||
| 117 | 117 | protected function createMigrationTable(): void |
| 118 | 118 | { |
| 119 | 119 | $tableName = $this->table; |
| 120 | - $this->schema->create($tableName, function (CreateTable $table) { |
|
| 120 | + $this->schema->create($tableName, function(CreateTable $table) { |
|
| 121 | 121 | $table->string('version', 20) |
| 122 | 122 | ->description('The migration version') |
| 123 | 123 | ->primary(); |
@@ -58,8 +58,7 @@ discard block |
||
| 58 | 58 | * class MigrationInitCommand |
| 59 | 59 | * @package Platine\Framework\Migration\Command |
| 60 | 60 | */ |
| 61 | -class MigrationInitCommand extends AbstractCommand |
|
| 62 | -{ |
|
| 61 | +class MigrationInitCommand extends AbstractCommand { |
|
| 63 | 62 | |
| 64 | 63 | /** |
| 65 | 64 | * The schema to use |
@@ -89,8 +88,7 @@ discard block |
||
| 89 | 88 | /** |
| 90 | 89 | * {@inheritodc} |
| 91 | 90 | */ |
| 92 | - public function execute() |
|
| 93 | - { |
|
| 91 | + public function execute() { |
|
| 94 | 92 | $io = $this->io(); |
| 95 | 93 | $writer = $io->writer(); |
| 96 | 94 | $writer->boldYellow('MIGRATION INITIALIZATION', true); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ) { |
| 81 | 81 | parent::__construct($app, $repository, $config, $filesystem); |
| 82 | 82 | $this->setName('migration:create') |
| 83 | - ->setDescription('Create a new migration'); |
|
| 83 | + ->setDescription('Create a new migration'); |
|
| 84 | 84 | |
| 85 | 85 | $this->addArgument('name', 'name of migration', null, false, true); |
| 86 | 86 | } |
@@ -158,26 +158,3 @@ discard block |
||
| 158 | 158 | private function getTemplateClass(): string |
| 159 | 159 | { |
| 160 | 160 | return <<<EOF |
| 161 | - <?php |
|
| 162 | - namespace Platine\Framework\Migration; |
|
| 163 | - |
|
| 164 | - use Platine\Framework\Migration\AbstractMigration; |
|
| 165 | - |
|
| 166 | - class %classname% extends AbstractMigration |
|
| 167 | - { |
|
| 168 | - |
|
| 169 | - public function up(): void |
|
| 170 | - { |
|
| 171 | - //Action when migrate up |
|
| 172 | - |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - public function down(): void |
|
| 176 | - { |
|
| 177 | - //Action when migrate down |
|
| 178 | - |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - EOF; |
|
| 182 | - } |
|
| 183 | -} |
|
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ) { |
| 73 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
| 74 | 74 | $this->setName('migration:exec') |
| 75 | - ->setDescription('Execute the migration up/down for one version'); |
|
| 75 | + ->setDescription('Execute the migration up/down for one version'); |
|
| 76 | 76 | |
| 77 | 77 | $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
| 78 | 78 | if (!in_array($val, ['up', 'down'])) { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | )); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - return $val; |
|
| 85 | + return $val; |
|
| 86 | 86 | }); |
| 87 | 87 | |
| 88 | 88 | $this->addOption('-i|--id', 'the migration version', null, false, true); |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | $this->setName('migration:exec') |
| 75 | 75 | ->setDescription('Execute the migration up/down for one version'); |
| 76 | 76 | |
| 77 | - $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
| 77 | + $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function($val) { |
|
| 78 | 78 | if (!in_array($val, ['up', 'down'])) { |
| 79 | 79 | throw new RuntimeException(sprintf( |
| 80 | 80 | 'Invalid argument type [%s], must be one of [up, down]', |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | protected function getExecuted(string $orderDir = 'ASC'): array |
| 215 | 215 | { |
| 216 | 216 | $migrations = $this->repository |
| 217 | - ->query() |
|
| 218 | - ->orderBy('version', $orderDir) |
|
| 219 | - ->all(); |
|
| 217 | + ->query() |
|
| 218 | + ->orderBy('version', $orderDir) |
|
| 219 | + ->all(); |
|
| 220 | 220 | $result = []; |
| 221 | 221 | |
| 222 | 222 | foreach ($migrations as $entity) { |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | protected function getMigrationClassName(string $description, string $version): string |
| 236 | 236 | { |
| 237 | 237 | return Str::camel($description, false) |
| 238 | - . Str::replaceFirst('_', '', $version); |
|
| 238 | + . Str::replaceFirst('_', '', $version); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | ) { |
| 73 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
| 74 | 74 | $this->setName('migration:status') |
| 75 | - ->setDescription('Show current status of your migrations'); |
|
| 75 | + ->setDescription('Show current status of your migrations'); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |