@@ -81,7 +81,7 @@ |
||
81 | 81 | ) { |
82 | 82 | parent::__construct($app, $repository, $config, $filesystem); |
83 | 83 | $this->setName('migration:create') |
84 | - ->setDescription('Create a new migration'); |
|
84 | + ->setDescription('Create a new migration'); |
|
85 | 85 | |
86 | 86 | $this->addArgument('name', 'name of migration', null, false, true); |
87 | 87 | } |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | * @template T |
62 | 62 | * @extends AbstractCommand<T> |
63 | 63 | */ |
64 | -class MigrationCreateCommand extends AbstractCommand |
|
65 | -{ |
|
64 | +class MigrationCreateCommand extends AbstractCommand { |
|
66 | 65 | /** |
67 | 66 | * The migration name |
68 | 67 | * @var string |
@@ -78,7 +77,7 @@ discard block |
||
78 | 77 | MigrationRepository $repository, |
79 | 78 | Config $config, |
80 | 79 | Filesystem $filesystem |
81 | - ) { |
|
80 | + ) { |
|
82 | 81 | parent::__construct($app, $repository, $config, $filesystem); |
83 | 82 | $this->setName('migration:create') |
84 | 83 | ->setDescription('Create a new migration'); |
@@ -89,8 +88,7 @@ discard block |
||
89 | 88 | /** |
90 | 89 | * {@inheritdoc} |
91 | 90 | */ |
92 | - public function execute() |
|
93 | - { |
|
91 | + public function execute() { |
|
94 | 92 | $writer = $this->io()->writer(); |
95 | 93 | |
96 | 94 | $version = date('Ymd_His'); |
@@ -113,7 +111,7 @@ discard block |
||
113 | 111 | |
114 | 112 | $io = $this->io(); |
115 | 113 | |
116 | - if ($io->confirm('Are you confirm the generation of new migration?', 'n')) { |
|
114 | + if ($io->confirm('Are you confirm the generation of new migration?', 'n')) { |
|
117 | 115 | $this->checkMigrationPath(); |
118 | 116 | $this->generateClass($fullPath, $className); |
119 | 117 | $writer->boldGreen(sprintf( |
@@ -131,7 +129,7 @@ discard block |
||
131 | 129 | $writer->boldYellow('MIGRATION GENERATION', true)->eol(); |
132 | 130 | |
133 | 131 | $name = $this->getArgumentValue('name'); |
134 | - if (!$name) { |
|
132 | + if (!$name) { |
|
135 | 133 | $io = $this->io(); |
136 | 134 | $name = $io->prompt('Enter the name of the migration', 'Migration description'); |
137 | 135 | } |
@@ -72,7 +72,7 @@ |
||
72 | 72 | ) { |
73 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
74 | 74 | $this->setName('migration:reset') |
75 | - ->setDescription('Rollback all migration done before'); |
|
75 | + ->setDescription('Rollback all migration done before'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * @template T |
59 | 59 | * @extends AbstractCommand<T> |
60 | 60 | */ |
61 | -class MigrationResetCommand extends AbstractCommand |
|
62 | -{ |
|
61 | +class MigrationResetCommand extends AbstractCommand { |
|
63 | 62 | /** |
64 | 63 | * Create new instance |
65 | 64 | * {@inheritdoc} |
@@ -69,7 +68,7 @@ discard block |
||
69 | 68 | MigrationRepository $repository, |
70 | 69 | Config $config, |
71 | 70 | Filesystem $filesystem |
72 | - ) { |
|
71 | + ) { |
|
73 | 72 | parent::__construct($app, $repository, $config, $filesystem); |
74 | 73 | $this->setName('migration:reset') |
75 | 74 | ->setDescription('Rollback all migration done before'); |
@@ -78,21 +77,20 @@ discard block |
||
78 | 77 | /** |
79 | 78 | * {@inheritdoc} |
80 | 79 | */ |
81 | - public function execute() |
|
82 | - { |
|
80 | + public function execute() { |
|
83 | 81 | $io = $this->io(); |
84 | 82 | $writer = $io->writer(); |
85 | 83 | $writer->boldYellow('ALL MIGRATION ROLLBACK', true)->eol(); |
86 | 84 | |
87 | 85 | $executed = $this->getExecuted('DESC'); |
88 | 86 | |
89 | - if (empty($executed)) { |
|
87 | + if (empty($executed)) { |
|
90 | 88 | $writer->boldGreen('No migration done before'); |
91 | 89 | return; |
92 | 90 | } |
93 | 91 | |
94 | 92 | $writer->bold('Migration list to be rollback:', true); |
95 | - foreach ($executed as $version => $entity) { |
|
93 | + foreach ($executed as $version => $entity) { |
|
96 | 94 | $writer->boldGreen( |
97 | 95 | sprintf(' * %s - %s', $version, $entity->description), |
98 | 96 | true |
@@ -101,10 +99,10 @@ discard block |
||
101 | 99 | |
102 | 100 | $writer->write('', true); |
103 | 101 | |
104 | - if ($io->confirm('Are you confirm the migration rollback ?', 'n')) { |
|
102 | + if ($io->confirm('Are you confirm the migration rollback ?', 'n')) { |
|
105 | 103 | /** @var MigrationExecuteCommand<T> $migrationExecute */ |
106 | 104 | $migrationExecute = $this->application->get(MigrationExecuteCommand::class); |
107 | - foreach ($executed as $version => $entity) { |
|
105 | + foreach ($executed as $version => $entity) { |
|
108 | 106 | $migrationExecute->executeMigrationDown($version, $entity->description); |
109 | 107 | } |
110 | 108 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | ) { |
74 | 74 | parent::__construct($app, $repository, $config, $filesystem); |
75 | 75 | $this->setName('migration:status') |
76 | - ->setDescription('Show current status of your migrations'); |
|
76 | + ->setDescription('Show current status of your migrations'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | * @template T |
60 | 60 | * @extends AbstractCommand<T> |
61 | 61 | */ |
62 | -class MigrationStatusCommand extends AbstractCommand |
|
63 | -{ |
|
62 | +class MigrationStatusCommand extends AbstractCommand { |
|
64 | 63 | /** |
65 | 64 | * Create new instance |
66 | 65 | * {@inheritdoc} |
@@ -70,7 +69,7 @@ discard block |
||
70 | 69 | MigrationRepository $repository, |
71 | 70 | Config $config, |
72 | 71 | Filesystem $filesystem |
73 | - ) { |
|
72 | + ) { |
|
74 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
75 | 74 | $this->setName('migration:status') |
76 | 75 | ->setDescription('Show current status of your migrations'); |
@@ -79,8 +78,7 @@ discard block |
||
79 | 78 | /** |
80 | 79 | * {@inheritdoc} |
81 | 80 | */ |
82 | - public function execute() |
|
83 | - { |
|
81 | + public function execute() { |
|
84 | 82 | $writer = $this->io()->writer(); |
85 | 83 | $writer->boldYellow('MIGRATION STATUS', true)->eol(); |
86 | 84 | $writer->bold('Migration path: '); |
@@ -99,7 +97,7 @@ discard block |
||
99 | 97 | $writer->boldYellow('MIGRATION LIST', true); |
100 | 98 | |
101 | 99 | $rows = []; |
102 | - foreach ($executed as $version => $entity) { |
|
100 | + foreach ($executed as $version => $entity) { |
|
103 | 101 | $rows[] = [ |
104 | 102 | 'version' => (string) $version, |
105 | 103 | 'description' => $entity->description, |
@@ -108,7 +106,7 @@ discard block |
||
108 | 106 | ]; |
109 | 107 | } |
110 | 108 | |
111 | - foreach ($diff as $version => $description) { |
|
109 | + foreach ($diff as $version => $description) { |
|
112 | 110 | $cleanDescription = str_replace('_', ' ', $description); |
113 | 111 | $version = (string) $version; |
114 | 112 | $rows[] = [ |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ) { |
82 | 82 | parent::__construct($app, $repository, $config, $filesystem); |
83 | 83 | $this->setName('migration:init') |
84 | - ->setDescription('Initialize the migration by creating migration table'); |
|
84 | + ->setDescription('Initialize the migration by creating 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(); |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | * @template T |
61 | 61 | * @extends AbstractCommand<T> |
62 | 62 | */ |
63 | -class MigrationInitCommand extends AbstractCommand |
|
64 | -{ |
|
63 | +class MigrationInitCommand extends AbstractCommand { |
|
65 | 64 | /** |
66 | 65 | * The schema to use |
67 | 66 | * @var Schema |
@@ -78,7 +77,7 @@ discard block |
||
78 | 77 | Schema $schema, |
79 | 78 | Config $config, |
80 | 79 | Filesystem $filesystem |
81 | - ) { |
|
80 | + ) { |
|
82 | 81 | parent::__construct($app, $repository, $config, $filesystem); |
83 | 82 | $this->setName('migration:init') |
84 | 83 | ->setDescription('Initialize the migration by creating migration table'); |
@@ -89,13 +88,12 @@ discard block |
||
89 | 88 | /** |
90 | 89 | * {@inheritdoc} |
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); |
97 | 95 | |
98 | - if ($this->schema->hasTable($this->table, true)) { |
|
96 | + if ($this->schema->hasTable($this->table, true)) { |
|
99 | 97 | $writer->boldRed(sprintf( |
100 | 98 | 'Migration table [%s] already created', |
101 | 99 | $this->table |
@@ -117,7 +115,7 @@ discard block |
||
117 | 115 | protected function createMigrationTable(): void |
118 | 116 | { |
119 | 117 | $tableName = $this->table; |
120 | - $this->schema->create($tableName, function (CreateTable $table) { |
|
118 | + $this->schema->create($tableName, function (CreateTable $table) { |
|
121 | 119 | $table->string('version', 20) |
122 | 120 | ->description('The migration version') |
123 | 121 | ->primary(); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | ) { |
74 | 74 | parent::__construct($app, $repository, $config, $filesystem); |
75 | 75 | $this->setName('migration:exec') |
76 | - ->setDescription('Execute the migration up/down for one version'); |
|
76 | + ->setDescription('Execute the migration up/down for one version'); |
|
77 | 77 | |
78 | 78 | $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
79 | 79 | if (!in_array($val, ['up', 'down'])) { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | )); |
84 | 84 | } |
85 | 85 | |
86 | - return $val; |
|
86 | + return $val; |
|
87 | 87 | }); |
88 | 88 | |
89 | 89 | $this->addOption('-i|--id', 'the migration version', null, false, true); |
@@ -75,7 +75,7 @@ |
||
75 | 75 | $this->setName('migration:exec') |
76 | 76 | ->setDescription('Execute the migration up/down for one version'); |
77 | 77 | |
78 | - $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
78 | + $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function($val) { |
|
79 | 79 | if (!in_array($val, ['up', 'down'])) { |
80 | 80 | throw new RuntimeException(sprintf( |
81 | 81 | 'Invalid argument type [%s], must be one of [up, down]', |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | * @template T |
60 | 60 | * @extends AbstractCommand<T> |
61 | 61 | */ |
62 | -class MigrationExecuteCommand extends AbstractCommand |
|
63 | -{ |
|
62 | +class MigrationExecuteCommand extends AbstractCommand { |
|
64 | 63 | /** |
65 | 64 | * Create new instance |
66 | 65 | * {@inheritdoc} |
@@ -70,13 +69,13 @@ discard block |
||
70 | 69 | MigrationRepository $repository, |
71 | 70 | Config $config, |
72 | 71 | Filesystem $filesystem |
73 | - ) { |
|
72 | + ) { |
|
74 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
75 | 74 | $this->setName('migration:exec') |
76 | 75 | ->setDescription('Execute the migration up/down for one version'); |
77 | 76 | |
78 | - $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
79 | - if (!in_array($val, ['up', 'down'])) { |
|
77 | + $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
78 | + if (!in_array($val, ['up', 'down'])) { |
|
80 | 79 | throw new RuntimeException(sprintf( |
81 | 80 | 'Invalid argument type [%s], must be one of [up, down]', |
82 | 81 | $val |
@@ -92,8 +91,7 @@ discard block |
||
92 | 91 | /** |
93 | 92 | * {@inheritdoc} |
94 | 93 | */ |
95 | - public function execute() |
|
96 | - { |
|
94 | + public function execute() { |
|
97 | 95 | $type = $this->getArgumentValue('type'); |
98 | 96 | |
99 | 97 | $io = $this->io(); |
@@ -104,43 +102,43 @@ discard block |
||
104 | 102 | $executed = $this->getExecuted('DESC'); |
105 | 103 | $version = $this->getOptionValue('id'); |
106 | 104 | |
107 | - if ($type === 'up') { |
|
105 | + if ($type === 'up') { |
|
108 | 106 | $diff = array_diff_key($migrations, $executed); |
109 | - if (empty($diff)) { |
|
107 | + if (empty($diff)) { |
|
110 | 108 | $writer->boldGreen('Migration already up to date'); |
111 | - } else { |
|
112 | - if (empty($version)) { |
|
109 | + } else { |
|
110 | + if (empty($version)) { |
|
113 | 111 | $version = $io->choice('Choose which version to migrate up', $diff); |
114 | 112 | } |
115 | 113 | |
116 | - if (!isset($diff[$version])) { |
|
114 | + if (!isset($diff[$version])) { |
|
117 | 115 | $writer->boldRed(sprintf( |
118 | 116 | 'Invalid migration version [%s] or already executed', |
119 | 117 | $version |
120 | 118 | )); |
121 | - } else { |
|
119 | + } else { |
|
122 | 120 | $description = str_replace('_', ' ', $migrations[$version]); |
123 | 121 | $this->executeMigrationUp($version, $description); |
124 | 122 | } |
125 | 123 | } |
126 | - } else { |
|
127 | - if (empty($executed)) { |
|
124 | + } else { |
|
125 | + if (empty($executed)) { |
|
128 | 126 | $writer->boldGreen('No migration to rollback'); |
129 | - } else { |
|
127 | + } else { |
|
130 | 128 | $data = []; |
131 | - foreach ($executed as $ver => $entity) { |
|
129 | + foreach ($executed as $ver => $entity) { |
|
132 | 130 | $data[$ver] = $entity->description; |
133 | 131 | } |
134 | - if (empty($version)) { |
|
132 | + if (empty($version)) { |
|
135 | 133 | $version = $io->choice('Choose which version to rollback', $data); |
136 | 134 | } |
137 | 135 | |
138 | - if (!isset($data[$version])) { |
|
136 | + if (!isset($data[$version])) { |
|
139 | 137 | $writer->boldRed(sprintf( |
140 | 138 | 'Invalid migration version [%s] or not yet executed', |
141 | 139 | $version |
142 | 140 | )); |
143 | - } else { |
|
141 | + } else { |
|
144 | 142 | $description = str_replace('_', ' ', $data[$version]); |
145 | 143 | $this->executeMigrationDown($version, $description); |
146 | 144 | } |
@@ -197,7 +195,7 @@ discard block |
||
197 | 195 | 'version' => $version |
198 | 196 | ]); |
199 | 197 | |
200 | - if ($entity) { |
|
198 | + if ($entity) { |
|
201 | 199 | $this->repository->delete($entity); |
202 | 200 | } |
203 | 201 | } |
@@ -53,8 +53,7 @@ |
||
53 | 53 | * @class AbstractMigration |
54 | 54 | * @package Platine\Framework\Migration |
55 | 55 | */ |
56 | -abstract class AbstractMigration extends Schema |
|
57 | -{ |
|
56 | +abstract class AbstractMigration extends Schema { |
|
58 | 57 | /** |
59 | 58 | * Execute when do migrate |
60 | 59 | * @return void |
@@ -55,14 +55,12 @@ |
||
55 | 55 | * @package Platine\Framework\Migration |
56 | 56 | * @extends Repository<MigrationEntity> |
57 | 57 | */ |
58 | -class MigrationRepository extends Repository |
|
59 | -{ |
|
58 | +class MigrationRepository extends Repository { |
|
60 | 59 | /** |
61 | 60 | * Create new instance |
62 | 61 | * @param EntityManager<MigrationEntity> $manager |
63 | 62 | */ |
64 | - public function __construct(EntityManager $manager) |
|
65 | - { |
|
63 | + public function __construct(EntityManager $manager) { |
|
66 | 64 | parent::__construct($manager, MigrationEntity::class); |
67 | 65 | } |
68 | 66 | } |
@@ -53,8 +53,7 @@ |
||
53 | 53 | * @class Base64UrlSafeEncoder |
54 | 54 | * @package Platine\Framework\Security\JWT\Encoder |
55 | 55 | */ |
56 | -class Base64UrlSafeEncoder implements EncoderInterface |
|
57 | -{ |
|
56 | +class Base64UrlSafeEncoder implements EncoderInterface { |
|
58 | 57 | /** |
59 | 58 | * {@inheritdoc} |
60 | 59 | */ |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class EncoderInterface |
52 | 52 | * @package Platine\Framework\Security\JWT |
53 | 53 | */ |
54 | -interface EncoderInterface |
|
55 | -{ |
|
54 | +interface EncoderInterface { |
|
56 | 55 | /** |
57 | 56 | * Encode the given data |
58 | 57 | * @param string $data |