Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code style fix #8

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/ClickhouseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static function (Application $app): ClickhouseClient {
$clickhouseClientFactory = new ClickhouseClientFactory($connectionConfig);

return $clickhouseClientFactory->create();
}
},
);

$this->app->singleton(
Expand All @@ -61,7 +61,7 @@ static function (Application $app): Migrator {
$repository,
$filesystem,
);
}
},
);

$this->app->singleton(
Expand All @@ -71,7 +71,7 @@ static function (Application $app): MigrationCreator {
$app->get(Filesystem::class),
$app->basePath('stubs'),
);
}
},
);
}

Expand Down Expand Up @@ -99,7 +99,7 @@ private function registerConsoleCommands(): void
[
ClickhouseMigrateCommand::class,
MakeClickhouseMigrationCommand::class,
]
],
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/ConsoleCommand/MakeClickhouseMigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
final class MakeClickhouseMigrationCommand extends Command
{
private MigrationCreator $creator;

private Composer $composer;

private AppConfigRepositoryInterface $appConfigRepository;

protected $description = 'Create a new ClickHouse migration file';
Expand Down Expand Up @@ -130,7 +132,7 @@ private function getMigrationPath(): string

return rtrim(
$this->appConfigRepository->get('clickhouse.migrations.path'),
'/'
'/',
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Migration/AbstractClickhouseMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

abstract class AbstractClickhouseMigration
{
protected ?Client $clickhouseClient;
protected Client $clickhouseClient;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot be null, because have fallback value in constructor:

$this->clickhouseClient = $clickhouseClient ?? app(Client::class);

protected string $databaseName;

public function __construct(
Expand Down
19 changes: 8 additions & 11 deletions src/Migration/MigrationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function createMigrationRegistryTable(): Statement
SQL,
[
'table' => $this->table,
]
],
);
}

Expand All @@ -62,7 +62,7 @@ public function all(): array
SQL,
[
'table' => $this->table,
]
],
)->rows();

return collect($rows)->pluck('migration')->all();
Expand All @@ -83,7 +83,7 @@ public function latest(): array
SQL,
[
'table' => $this->table,
]
],
)->rows();

return collect($rows)->pluck('migration')->all();
Expand All @@ -104,7 +104,7 @@ public function getLastBatchNumber(): int
SQL,
[
'table' => $this->table,
]
],
)
->fetchOne('batch');
}
Expand All @@ -116,13 +116,10 @@ public function add(
return $this->client->insert(
$this->table,
[[$migration, $batch]],
['migration', 'batch']
['migration', 'batch'],
);
}

/**
* @return int
*/
public function total(): int
{
return (int)$this->client->select(
Expand All @@ -132,7 +129,7 @@ public function total(): int
SQL,
[
'table' => $this->table,
]
],
)->fetchOne('count');
}

Expand All @@ -144,7 +141,7 @@ public function exists(): bool
SQL,
[
'table' => $this->table,
]
],
)->fetchOne('result');
}

Expand All @@ -165,7 +162,7 @@ public function find(
[
'table' => $this->table,
'migration' => $migration,
]
],
)->fetchOne();
}
}
12 changes: 6 additions & 6 deletions src/Migration/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function runUp(

if ($migrations->valid() === false) {
$output->writeln(
'<info>Migrations are empty.</info>'
'<info>Migrations are empty.</info>',
);

return;
Expand All @@ -76,7 +76,7 @@ public function runUp(
$this->repository->add($migrationName, $nextBatch);

$output->writeln(
"<info>Completed in {$runTime} seconds</info> {$migrationName}"
"<info>Completed in {$runTime} seconds</info> {$migrationName}",
);

$migrations->next();
Expand Down Expand Up @@ -109,7 +109,7 @@ private function getMigrationName(
}

/**
* @return SplFileInfo[]
* @return list<SplFileInfo>
*/
private function getUnAppliedMigrationFiles(
string $migrationsDirectoryPath
Expand All @@ -120,7 +120,7 @@ private function getUnAppliedMigrationFiles(
->reject(
fn(SplFileInfo $migrationFile) => $this->isAppliedMigration(
$migrationFile->getFilename(),
)
),
)->all();
}

Expand All @@ -145,7 +145,7 @@ private function generateMigrationClassName(
string $migrationName
): string {
return Str::studly(
implode('_', array_slice(explode('_', $migrationName), 4))
implode('_', array_slice(explode('_', $migrationName), 4)),
);
}

Expand All @@ -167,7 +167,7 @@ private function isAppliedMigration(
return in_array(
$this->getMigrationName($fileName),
$this->repository->all(),
true
true,
);
}
}
Loading