From aade1385e579848629b15897c40e39db3e3fa294 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 12 Jul 2024 09:38:12 +0000 Subject: [PATCH] Apply fixes from StyleCI --- monorepo/DevTools/src/RefactorConfigCommand.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/monorepo/DevTools/src/RefactorConfigCommand.php b/monorepo/DevTools/src/RefactorConfigCommand.php index 0b7204d463a..8613976ff39 100644 --- a/monorepo/DevTools/src/RefactorConfigCommand.php +++ b/monorepo/DevTools/src/RefactorConfigCommand.php @@ -4,11 +4,8 @@ namespace Hyde\MonorepoDevTools; -use Enum; -use UnitEnum; use Hyde\Hyde; use Throwable; -use BackedEnum; use Hyde\Enums\Feature; use Illuminate\Support\Str; use Symfony\Component\Yaml\Yaml; @@ -21,7 +18,6 @@ use function substr; use function unlink; use function collect; -use function gettype; use function implode; use function in_array; use function is_array; @@ -46,12 +42,13 @@ class RefactorConfigCommand extends Command public function handle(): int { $format = $this->argument('format'); - if (!in_array($format, self::FORMATS)) { - $this->error('Invalid format. Supported formats: ' . implode(', ', self::FORMATS)); + if (! in_array($format, self::FORMATS)) { + $this->error('Invalid format. Supported formats: '.implode(', ', self::FORMATS)); + return 1; } - $this->gray(' > Migrating configuration to ' . $format); + $this->gray(' > Migrating configuration to '.$format); match ($format) { 'yaml' => $this->migrateToYaml(), @@ -64,12 +61,11 @@ public function handle(): int protected function migrateToYaml(): void { - if (file_exists(Hyde::path('hyde.yml')) && !file_exists(Hyde::path('hyde.yml.bak'))) { + if (file_exists(Hyde::path('hyde.yml')) && ! file_exists(Hyde::path('hyde.yml.bak'))) { copy(Hyde::path('hyde.yml'), Hyde::path('hyde.yml.bak')); } try { - $config = config('hyde'); $config = $this->serializePhpData($config); @@ -79,10 +75,11 @@ protected function migrateToYaml(): void file_put_contents(Hyde::path('hyde.yml'), $yaml); } catch (Throwable $exception) { - $this->error('Failed to migrate configuration: ' . $exception->getMessage()); + $this->error('Failed to migrate configuration: '.$exception->getMessage()); $this->warn('Rolling back changes...'); copy(Hyde::path('hyde.yml.bak'), Hyde::path('hyde.yml')); unlink(Hyde::path('hyde.yml.bak')); + return; } }