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
Changes from all commits
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
@@ -40,7 +40,7 @@ static function (Application $app): ClickhouseClient {
$clickhouseClientFactory = new ClickhouseClientFactory($connectionConfig);

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

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

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

@@ -99,7 +99,7 @@ private function registerConsoleCommands(): void
[
ClickhouseMigrateCommand::class,
MakeClickhouseMigrationCommand::class,
]
],
);
}
}
2 changes: 1 addition & 1 deletion src/ConsoleCommand/MakeClickhouseMigrationCommand.php
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ private function getMigrationPath(): string

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

2 changes: 1 addition & 1 deletion src/Migration/AbstractClickhouseMigration.php
Original file line number Diff line number Diff line change
@@ -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(
19 changes: 8 additions & 11 deletions src/Migration/MigrationRepository.php
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ public function createMigrationRegistryTable(): Statement
SQL,
[
'table' => $this->table,
]
],
);
}

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

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

return collect($rows)->pluck('migration')->all();
@@ -104,7 +104,7 @@ public function getLastBatchNumber(): int
SQL,
[
'table' => $this->table,
]
],
)
->fetchOne('batch');
}
@@ -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(
@@ -132,7 +129,7 @@ public function total(): int
SQL,
[
'table' => $this->table,
]
],
)->fetchOne('count');
}

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

@@ -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
@@ -53,7 +53,7 @@ public function runUp(

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

return;
@@ -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();
@@ -109,7 +109,7 @@ private function getMigrationName(
}

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

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