Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Jul 12, 2024
1 parent aad374f commit aade138
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions monorepo/DevTools/src/RefactorConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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(),
Expand All @@ -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);

Expand All @@ -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;
}
}
Expand Down

0 comments on commit aade138

Please sign in to comment.