Skip to content

Commit

Permalink
Run CS
Browse files Browse the repository at this point in the history
  • Loading branch information
apfelbox committed Sep 19, 2024
1 parent eefb7d9 commit d8f6c67
Show file tree
Hide file tree
Showing 26 changed files with 62 additions and 62 deletions.
14 changes: 7 additions & 7 deletions src/Api/ContentApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function fetchSingleStory (
}
catch (ExceptionInterface $exception)
{
throw new ContentRequestFailedException(sprintf(
throw new ContentRequestFailedException(\sprintf(
"Content request failed for single story '%s': %s",
$identifier,
$exception->getMessage(),
Expand Down Expand Up @@ -136,7 +136,7 @@ public function fetchStories (
{
if (!is_a($story, $storyType))
{
throw new InvalidDataException(sprintf(
throw new InvalidDataException(\sprintf(
"Requested stories for type '%s', but encountered story of type '%s'.",
$storyType,
$story::class,
Expand Down Expand Up @@ -242,7 +242,7 @@ public function getSpaceInfo () : SpaceInfo
"name" => $spaceInfo->getName(),
]);

throw new InvalidConfigException(sprintf(
throw new InvalidConfigException(\sprintf(
"Invalid storyblok config: configured space id is '%s', but content token belongs to space id '%s' (name '%s')",
$this->config->getSpaceId(),
$spaceInfo->getId(),
Expand All @@ -254,7 +254,7 @@ public function getSpaceInfo () : SpaceInfo
}
catch (ExceptionInterface $exception)
{
throw new ContentRequestFailedException(sprintf(
throw new ContentRequestFailedException(\sprintf(
"Failed to fetch space info: %s",
$exception->getMessage(),
), previous: $exception);
Expand Down Expand Up @@ -336,7 +336,7 @@ private function fetchStoriesResultPage (
}
catch (ExceptionInterface $exception)
{
throw new ContentRequestFailedException(sprintf(
throw new ContentRequestFailedException(\sprintf(
"Content request failed: %s",
$exception->getMessage(),
), previous: $exception);
Expand Down Expand Up @@ -474,7 +474,7 @@ private function fetchDatasourceEntriesResultPage (
}
catch (ExceptionInterface $exception)
{
throw new ContentRequestFailedException(sprintf(
throw new ContentRequestFailedException(\sprintf(
"Content request failed: %s",
$exception->getMessage(),
), previous: $exception);
Expand Down Expand Up @@ -585,7 +585,7 @@ private function fetchLinksResultPage (
}
catch (ExceptionInterface $exception)
{
throw new ContentRequestFailedException(sprintf(
throw new ContentRequestFailedException(\sprintf(
"Content request failed: %s",
$exception->getMessage(),
), previous: $exception);
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Data/SpaceInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ public function getDomain () : string
*/
public function getBackendDashboardUrl () : string
{
return sprintf("https://app.storyblok.com/#/me/spaces/%d/dashboard", $this->spaceId);
return \sprintf("https://app.storyblok.com/#/me/spaces/%d/dashboard", $this->spaceId);
}
}
22 changes: 11 additions & 11 deletions src/Api/ManagementApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct (
$this->client = new RetryableHttpClient(
$client->withOptions(
(new HttpOptions())
->setBaseUri(sprintf(self::API_URL, $this->config->getSpaceId()))
->setBaseUri(\sprintf(self::API_URL, $this->config->getSpaceId()))
->toArray(),
),
);
Expand Down Expand Up @@ -218,7 +218,7 @@ private function fetchFreshComponentIdMap () : ComponentIdMap
}
catch (ExceptionInterface $e)
{
throw new ApiRequestFailedException(sprintf(
throw new ApiRequestFailedException(\sprintf(
"Failed to fetch existing components: %s",
$e->getMessage(),
), previous: $e);
Expand All @@ -233,10 +233,10 @@ public function syncDatasourceEntries (
?TorrStyle $io = null,
) : void
{
$io?->writeln(sprintf("• Fetching the id for datasource <fg=blue>%s</>", $datasourceSlug));
$io?->writeln(\sprintf("• Fetching the id for datasource <fg=blue>%s</>", $datasourceSlug));

$datasourceId = $this->getDatasourceId($datasourceSlug);
$io?->writeln(sprintf("• Found id <fg=yellow>%d</>", $datasourceId));
$io?->writeln(\sprintf("• Found id <fg=yellow>%d</>", $datasourceId));

$nameMap = [];
$valueMap = [];
Expand Down Expand Up @@ -271,7 +271,7 @@ public function syncDatasourceEntries (
// if new entry
if (\array_key_exists($name, $nameMap))
{
throw new DatasourceSyncFailedException(sprintf(
throw new DatasourceSyncFailedException(\sprintf(
"Duplicate datasource name for name '%s' found, one new with key '%s' and existing '%s'.",
$name,
$value,
Expand All @@ -286,11 +286,11 @@ public function syncDatasourceEntries (
];
}

$io?->writeln(sprintf("• Found <fg=blue>%d</> entries to add", \count($toAdd)));
$io?->writeln(\sprintf("• Found <fg=blue>%d</> entries to add", \count($toAdd)));

foreach ($toAdd as $entry)
{
$io?->writeln(sprintf("• Adding <fg=yellow>%s</>", $entry["name"]));
$io?->writeln(\sprintf("• Adding <fg=yellow>%s</>", $entry["name"]));
$this->sendRequest(
"datasource_entries",
options: (new HttpOptions())
Expand All @@ -301,11 +301,11 @@ public function syncDatasourceEntries (
);
}

$io?->writeln(sprintf("• Found <fg=blue>%d</> entries to update", \count($toUpdate)));
$io?->writeln(\sprintf("• Found <fg=blue>%d</> entries to update", \count($toUpdate)));

foreach ($toUpdate as $entry)
{
$io?->writeln(sprintf("• Updating <fg=yellow>%s</>", $entry["name"]));
$io?->writeln(\sprintf("• Updating <fg=yellow>%s</>", $entry["name"]));
$this->sendRequest(
"datasource_entries/{$entry["id"]}",
options: (new HttpOptions())
Expand Down Expand Up @@ -355,7 +355,7 @@ private function getDatasourceId (
}
}

throw new DatasourceSyncFailedException(sprintf(
throw new DatasourceSyncFailedException(\sprintf(
"Could not find data source id for datasource '%s'",
$datasourceSlug,
));
Expand Down Expand Up @@ -404,7 +404,7 @@ private function sendRequest (
"response" => $response?->getContent(false),
]);

throw new ApiRequestFailedException(sprintf(
throw new ApiRequestFailedException(\sprintf(
"Failed management request %s '%s': %s",
$method,
$path,
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/StoryblokBackendUrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function generateStoryEditUrl (StoryInterface $story) : string
*/
public function generateStoryEditUrlById (int $storyId) : string
{
return sprintf(
return \sprintf(
"https://app.storyblok.com/#/me/spaces/%d/stories/0/0/%d",
$this->config->getSpaceId(),
$storyId,
Expand Down
12 changes: 6 additions & 6 deletions src/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function execute (InputInterface $input, OutputInterface $output) : in
// TODO v4: remove check
if ("storyblok:debug" !== $input->getFirstArgument())
{
$message = sprintf(
$message = \sprintf(
"The command `%s` is deprecated. Use `%s` instead.",
$input->getFirstArgument(),
"storyblok:debug",
Expand All @@ -67,7 +67,7 @@ protected function execute (InputInterface $input, OutputInterface $output) : in
}
catch (StoryblokException $exception)
{
$io->error(sprintf(
$io->error(\sprintf(
"Failed to show debug info: %s",
$exception->getMessage(),
));
Expand All @@ -82,7 +82,7 @@ protected function execute (InputInterface $input, OutputInterface $output) : in
private function showInfo (TorrStyle $io) : void
{
$spaceInfo = $this->contentApi->getSpaceInfo();
$color = static fn (string $color, string|int $text) => sprintf("<fg=%s>%s</>", $color, $text);
$color = static fn (string $color, string|int $text) => \sprintf("<fg=%s>%s</>", $color, $text);

$io->definitionList(
["Space ID" => $color("magenta", $spaceInfo->getId())],
Expand Down Expand Up @@ -137,12 +137,12 @@ private function fetchOverview (bool $verbose) : array

if (null === $details)
{
$unregistered[] = sprintf("<fg=red>%s</>", $componentKey);
$unregistered[] = \sprintf("<fg=red>%s</>", $componentKey);
continue;
}

$registered[] = [
sprintf("<fg=yellow>%s</>", $componentKey),
\sprintf("<fg=yellow>%s</>", $componentKey),
...$details,
];
}
Expand All @@ -167,7 +167,7 @@ private function getComponentDetails (string $componentKey, bool $verbose) : ?ar
$className = u($className)->afterLast("\\")->toString();
}

return sprintf("<fg=blue>%s</>", $className);
return \sprintf("<fg=blue>%s</>", $className);
};

try
Expand Down
6 changes: 3 additions & 3 deletions src/Command/SyncDefinitionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function execute (InputInterface $input, OutputInterface $output) : in

$spaceInfo = $this->contentApi->getSpaceInfo();

$io->comment(sprintf(
$io->comment(\sprintf(
"Syncing components for space <fg=magenta>%s</> (<fg=yellow>%d</>)\n<fg=gray>%s</>",
$spaceInfo->getName(),
$spaceInfo->getId(),
Expand All @@ -76,14 +76,14 @@ protected function execute (InputInterface $input, OutputInterface $output) : in
}
catch (ValidationFailedException $exception)
{
$io->comment(sprintf("<fg=red>ERROR</>\n%s", $exception->getMessage()));
$io->comment(\sprintf("<fg=red>ERROR</>\n%s", $exception->getMessage()));
$io->error("Validation failed");

return self::FAILURE;
}
catch (SyncFailedException $exception)
{
$io->comment(sprintf("<fg=red>ERROR</>\n%s", $exception->getMessage()));
$io->comment(\sprintf("<fg=red>ERROR</>\n%s", $exception->getMessage()));
$io->error("Sync failed");

return self::FAILURE;
Expand Down
4 changes: 2 additions & 2 deletions src/Command/ValidateDefinitionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function execute (InputInterface $input, OutputInterface $output) : in

$spaceInfo = $this->contentApi->getSpaceInfo();

$io->comment(sprintf(
$io->comment(\sprintf(
"Validating components for space <fg=magenta>%s</> (<fg=yellow>%d</>)\n<fg=gray>%s</>",
$spaceInfo->getName(),
$spaceInfo->getId(),
Expand All @@ -53,7 +53,7 @@ protected function execute (InputInterface $input, OutputInterface $output) : in
}
catch (ValidationFailedException $exception)
{
$io->comment(sprintf("<fg=red>ERROR</>\n%s", $exception->getMessage()));
$io->comment(\sprintf("<fg=red>ERROR</>\n%s", $exception->getMessage()));
$io->error("Definitions validation failed");

return self::FAILURE;
Expand Down
10 changes: 5 additions & 5 deletions src/Component/AbstractComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function validateData (
{
$contentPath = [
...$contentPath,
sprintf("Component(%s, '%s')", static::getKey(), $label ?? "n/a"),
\sprintf("Component(%s, '%s')", static::getKey(), $label ?? "n/a"),
];

// validate base data
Expand Down Expand Up @@ -203,7 +203,7 @@ public function validateData (
$context,
[
...$contentPath,
sprintf("Field(%s)", $name),
\sprintf("Field(%s)", $name),
],
$fieldData,
$data,
Expand All @@ -227,7 +227,7 @@ private function normalizeFields (
{
if (empty($fields))
{
throw new InvalidComponentConfigurationException(sprintf(
throw new InvalidComponentConfigurationException(\sprintf(
"Invalid component '%s': can't have a component without fields",
static::class,
));
Expand All @@ -239,7 +239,7 @@ private function normalizeFields (
{
if (ComponentHelper::isReservedKey($key))
{
throw new InvalidComponentConfigurationException(sprintf(
throw new InvalidComponentConfigurationException(\sprintf(
"Invalid component configuration '%s': can't use '%s' as field key, as that is a reserved key.",
static::class,
$key,
Expand All @@ -261,7 +261,7 @@ final public function toManagementApiData () : array
{
if (ComponentHelper::isReservedKey(static::getKey()))
{
throw new InvalidComponentConfigurationException(sprintf(
throw new InvalidComponentConfigurationException(\sprintf(
"Invalid component configuration '%s': can't use '%s' as component key, as that is a reserved key.",
static::class,
static::getKey(),
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Definition/ComponentDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct (
{
if (null !== $this->iconBackgroundColor && !preg_match('~^#(\\d{3}|\\d{6})$~', $this->iconBackgroundColor))
{
throw new InvalidComponentConfigurationException(sprintf(
throw new InvalidComponentConfigurationException(\sprintf(
"Invalid component configuration: icon background color must be hex with #, but is %s",
$this->iconBackgroundColor,
));
Expand Down
2 changes: 1 addition & 1 deletion src/Config/StoryblokConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getContentToken () : string
*/
public function getStoryblokSpaceUrl () : string
{
return sprintf("https://app.storyblok.com/#/me/spaces/%d/dashboard", $this->getSpaceId());
return \sprintf("https://app.storyblok.com/#/me/spaces/%d/dashboard", $this->getSpaceId());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Choices/EnumChoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct (
{
if (!is_a($this->enumType, BackedEnumChoiceInterface::class, true))
{
throw new InvalidFieldConfigurationException(sprintf(
throw new InvalidFieldConfigurationException(\sprintf(
"Enum type in EnumChoices must implement %s, but %s given",
BackedEnumChoiceInterface::class,
$this->enumType,
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Collection/FieldCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getField (string $key) : FieldDefinitionInterface

if (null === $field)
{
throw new UnknownFieldException(sprintf(
throw new UnknownFieldException(\sprintf(
"Unknown field %s",
$key,
));
Expand Down
4 changes: 2 additions & 2 deletions src/Field/Definition/BloksField.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function validateData (ComponentContext $context, array $contentPath, mix
if (null !== $this->minimumNumberOfBloks && $noOfKnownContainedBloks < $this->minimumNumberOfBloks)
{
throw new InvalidDataException(
sprintf("Found %d (known) components, but was expecting at least %d", $noOfKnownContainedBloks, $this->minimumNumberOfBloks),
\sprintf("Found %d (known) components, but was expecting at least %d", $noOfKnownContainedBloks, $this->minimumNumberOfBloks),
$contentPath,
$this,
$data,
Expand All @@ -139,7 +139,7 @@ public function validateData (ComponentContext $context, array $contentPath, mix
if (null !== $this->maximumNumberOfBloks && $noOfKnownContainedBloks > $this->maximumNumberOfBloks)
{
throw new InvalidDataException(
sprintf("Found %d (known) components, but was expecting at most %d", $noOfKnownContainedBloks, $this->maximumNumberOfBloks),
\sprintf("Found %d (known) components, but was expecting at most %d", $noOfKnownContainedBloks, $this->maximumNumberOfBloks),
$contentPath,
$this,
$data,
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Definition/RichTextField.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private function transformDataToRichTextArray (string $data) : ?array
{
return (new HtmlToRichTextTransformer())
->parseHtmlToRichText(
sprintf("<p>%s</p>", $data),
\sprintf("<p>%s</p>", $data),
);
}
}
2 changes: 1 addition & 1 deletion src/Field/Group/AbstractGroupingElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function validateData (ComponentContext $context, array $contentPath, mix
$context,
[
...$contentPath,
sprintf("Field(%s)", $name),
\sprintf("Field(%s)", $name),
],
$fieldData,
$fullData,
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Group/CompositeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function validateData (ComponentContext $context, array $contentPath, mix
$context,
[
...$contentPath,
sprintf("Field(%s)", $name),
\sprintf("Field(%s)", $name),
],
$fullData[$name] ?? null,
$fullData,
Expand Down
2 changes: 1 addition & 1 deletion src/Management/ManagementApiData.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function registerField (string $key, array $config) : void
{
if (\array_key_exists($key, $this->fields))
{
throw new InvalidComponentConfigurationException(sprintf(
throw new InvalidComponentConfigurationException(\sprintf(
"Invalid component configuration: field key '%s' used more than once",
$key,
));
Expand Down
Loading

0 comments on commit d8f6c67

Please sign in to comment.