Skip to content

Commit

Permalink
Fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Aug 7, 2024
1 parent 833d889 commit e1b8719
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"symfony/flex": true
"symfony/flex": true,
"php-http/discovery": true
}
}
}
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->validate()
->ifTrue(fn (array $config): bool => $config['default_connection'] && !\array_key_exists($config['default_connection'], $config['connections']))
->then(function (array $v) {
throw new InvalidConfigurationException(sprintf('The default connection "%s" does not exists. Available connections are: "%s".', $v['default_connection'], implode('", "', array_keys($v['connections']))));
throw new InvalidConfigurationException(\sprintf('The default connection "%s" does not exists. Available connections are: "%s".', $v['default_connection'], implode('", "', array_keys($v['connections']))));
})
->end()
;
Expand Down
10 changes: 5 additions & 5 deletions src/IndexBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public function createIndex(string $indexName, array $context = []): Index
{
$mapping = $this->mappingProvider->provideMapping($indexName, $context);

$realName = sprintf('%s_%s', $indexName, date('Y-m-d-His'));
$realName = \sprintf('%s_%s', $indexName, date('Y-m-d-His'));
$index = $this->client->getIndex($realName);

if ($index->exists()) {
throw new RuntimeException(sprintf('Index "%s" is already created, something is wrong.', $index->getName()));
throw new RuntimeException(\sprintf('Index "%s" is already created, something is wrong.', $index->getName()));
}

$index->create($mapping ?? []);
Expand Down Expand Up @@ -97,7 +97,7 @@ public function migrate(Index $currentIndex, array $params = [], array $context
$response = $reindex->run();

if (!$response->isOk()) {
throw new RuntimeException(sprintf('Reindex call failed. %s', $response->getError()));
throw new RuntimeException(\sprintf('Reindex call failed. %s', $response->getError()));
}

$taskId = $response->getData()['task'];
Expand Down Expand Up @@ -172,14 +172,14 @@ public function purgeOldIndices(string $indexName, bool $dryRun = false): array
$index = new \Elastica\Index($this->client, $realIndexName);
$index->delete();
}
$operations[] = sprintf('%s deleted.', $realIndexName);
$operations[] = \sprintf('%s deleted.', $realIndexName);
} elseif ($livePassed && 1 === $afterLiveCounter) {
// Close
if (false === $dryRun) {
$index = new \Elastica\Index($this->client, $realIndexName);
$index->close();
}
$operations[] = sprintf('%s closed.', $realIndexName);
$operations[] = \sprintf('%s closed.', $realIndexName);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/IndexNameMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(?string $prefix, array $indexClassMapping)
public function getPrefixedIndex(string $name): string
{
if ($this->prefix) {
return sprintf('%s_%s', $this->prefix, $name);
return \sprintf('%s_%s', $this->prefix, $name);
}

return $name;
Expand All @@ -42,7 +42,7 @@ public function getIndexNameFromClass(string $className): string
$indexName = array_search($className, $this->indexClassMapping, true);

if (!$indexName) {
throw new RuntimeException(sprintf('The given type (%s) does not exist in the configuration.', $className));
throw new RuntimeException(\sprintf('The given type (%s) does not exist in the configuration.', $className));
}

return $this->getPrefixedIndex($indexName);
Expand All @@ -54,7 +54,7 @@ public function getIndexNameFromClass(string $className): string
public function getClassFromIndexName(string $indexName): string
{
if (!isset($this->indexClassMapping[$indexName])) {
throw new RuntimeException(sprintf('Unknown class for index "%s". Please check your configuration.', $indexName));
throw new RuntimeException(\sprintf('Unknown class for index "%s". Please check your configuration.', $indexName));
}

return $this->indexClassMapping[$indexName];
Expand All @@ -63,7 +63,7 @@ public function getClassFromIndexName(string $indexName): string
public function getPureIndexName(string $fullIndexName): string
{
if ($this->prefix) {
$pattern = sprintf('/%s_(.+)_\d{4}-\d{2}-\d{2}-\d+/i', preg_quote($this->prefix, '/'));
$pattern = \sprintf('/%s_(.+)_\d{4}-\d{2}-\d{2}-\d+/i', preg_quote($this->prefix, '/'));
} else {
$pattern = '/(.+)_\d{4}-\d{2}-\d{2}-\d+/i';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/PhpProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function provideMapping(string $indexName, array $context = []): ?array
$fileName = $context['filename'] ?? ($indexName . '_mapping.php');
$mappingFilePath = $this->configurationDirectory . \DIRECTORY_SEPARATOR . $fileName;
if (!is_file($mappingFilePath)) {
throw new InvalidException(sprintf('Mapping file "%s" not found.', $mappingFilePath));
throw new InvalidException(\sprintf('Mapping file "%s" not found.', $mappingFilePath));
}

$mapping = require $mappingFilePath;
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/YamlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function provideMapping(string $indexName, array $context = []): ?array
$fileName = $context['filename'] ?? ($indexName . '_mapping.yaml');
$mappingFilePath = $this->configurationDirectory . \DIRECTORY_SEPARATOR . $fileName;
if (!is_file($mappingFilePath)) {
throw new InvalidException(sprintf('Mapping file "%s" not found. Please check your configuration.', $mappingFilePath));
throw new InvalidException(\sprintf('Mapping file "%s" not found. Please check your configuration.', $mappingFilePath));
}

$mapping = $this->parser->parseFile($mappingFilePath);
Expand Down
2 changes: 1 addition & 1 deletion src/Messenger/IndexationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class IndexationRequest implements IndexationRequestInterface
public function __construct(string $className, string $id, string $operation = IndexationRequestHandler::OP_INDEX)
{
if (!\in_array($operation, IndexationRequestHandler::OPERATIONS, true)) {
throw new \InvalidArgumentException(sprintf('Not supported operation "%s" given.', $operation));
throw new \InvalidArgumentException(\sprintf('Not supported operation "%s" given.', $operation));
}

$this->className = $className;
Expand Down
4 changes: 2 additions & 2 deletions tests/Symfony/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ protected function configureRoutes($routes): void
$routes->add('/with_response', TestController::class . '::withResponse', 'with_response');
} else {
$routeConfigurator = $routes->add('with_exception', '/with_exception');
$routeConfigurator->controller(sprintf('%s::withException', TestController::class));
$routeConfigurator->controller(\sprintf('%s::withException', TestController::class));

$routeConfigurator = $routes->add('with_response', '/with_response');
$routeConfigurator->controller(sprintf('%s::withResponse', TestController::class));
$routeConfigurator->controller(\sprintf('%s::withResponse', TestController::class));
}
}
}

0 comments on commit e1b8719

Please sign in to comment.