Skip to content

Commit d2da2e2

Browse files
committed
fabbot
1 parent 15e8900 commit d2da2e2

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

src/Icons/src/Command/ImportIconCommand.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6666
}
6767

6868
foreach ($prefixIcons as $prefix => $icons) {
69-
7069
if (!$this->iconify->hasIconSet($prefix)) {
7170
$io->error(\sprintf('Icon set "%s" not found.', $prefix));
7271
$result = Command::FAILURE;
@@ -78,46 +77,45 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7877
$io->newLine();
7978
$io->writeln(\sprintf(' Icon set: %s (License: %s)', $metadata['name'], $metadata['license']['title']));
8079

81-
foreach ($this->iconify->chunk($prefix, \array_keys($icons)) as $iconNames) {
82-
80+
foreach ($this->iconify->chunk($prefix, array_keys($icons)) as $iconNames) {
8381
$cursor = new Cursor($output);
8482
foreach ($iconNames as $name) {
8583
$io->writeln(\sprintf(' Importing %s:%s ...', $prefix, $name));
8684
}
87-
$cursor->moveUp(count($iconNames));
85+
$cursor->moveUp(\count($iconNames));
8886

8987
try {
9088
$batchResults = $this->iconify->fetchIcons($prefix, $iconNames);
9189
} catch (\InvalidArgumentException $e) {
9290
// At this point no exception should be thrown
9391
$io->error($e->getMessage());
9492

95-
return COMMAND::FAILURE;
93+
return Command::FAILURE;
9694
}
9795

9896
foreach ($iconNames as $name) {
9997
$cursor->clearLineAfter();
10098

10199
// If the icon is not found, the value will be null
102100
if (null === $icon = $batchResults[$name] ?? null) {
103-
$io->writeln(\sprintf(" <fg=red;options=bold>✗</> Not Found <fg=bright-white;bg=black>%s:</><fg=bright-red;bg=black>%s</>", $prefix, $name));
101+
$io->writeln(\sprintf(' <fg=red;options=bold>✗</> Not Found <fg=bright-white;bg=black>%s:</><fg=bright-red;bg=black>%s</>', $prefix, $name));
104102

105103
continue;
106104
}
107105

108106
++$importedIcons;
109107
$this->registry->add(\sprintf('%s/%s', $prefix, $name), (string) $icon);
110-
$io->writeln(\sprintf(" <fg=bright-green;options=bold>✓</> Imported <fg=bright-white;bg=black>%s:</><fg=bright-magenta;bg=black;options>%s</>", $prefix, $name));
108+
$io->writeln(\sprintf(' <fg=bright-green;options=bold>✓</> Imported <fg=bright-white;bg=black>%s:</><fg=bright-magenta;bg=black;options>%s</>', $prefix, $name));
111109
}
112110
}
113111
}
114112

115-
if ($importedIcons === $totalIcons = count($names)) {
116-
$io->success(sprintf('Imported %d/%d icons.', $importedIcons, $totalIcons));
113+
if ($importedIcons === $totalIcons = \count($names)) {
114+
$io->success(\sprintf('Imported %d/%d icons.', $importedIcons, $totalIcons));
117115
} elseif ($importedIcons > 0) {
118-
$io->warning(sprintf('Imported %d/%d icons.', $importedIcons, $totalIcons));
116+
$io->warning(\sprintf('Imported %d/%d icons.', $importedIcons, $totalIcons));
119117
} else {
120-
$io->error(sprintf('Imported %d/%d icons.', $importedIcons, $totalIcons));
118+
$io->error(\sprintf('Imported %d/%d icons.', $importedIcons, $totalIcons));
121119
$result = Command::FAILURE;
122120
}
123121

src/Icons/src/Iconify.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@ public function searchIcons(string $prefix, string $query)
165165
*/
166166
public function chunk(string $prefix, array $names): iterable
167167
{
168-
if (100 < ($prefixLength = strlen($prefix))) {
169-
throw new \InvalidArgumentException(sprintf('The icon prefix "%s" is too long.', $prefix));
168+
if (100 < ($prefixLength = \strlen($prefix))) {
169+
throw new \InvalidArgumentException(\sprintf('The icon prefix "%s" is too long.', $prefix));
170170
}
171171

172172
$maxLength = $this->maxIconsQueryLength - $prefixLength;
173173

174174
$curBatch = [];
175175
$curLength = 0;
176176
foreach ($names as $name) {
177-
if (100 < ($nameLength = strlen($name))) {
178-
throw new \InvalidArgumentException(sprintf('The icon name "%s" is too long.', $name));
177+
if (100 < ($nameLength = \strlen($name))) {
178+
throw new \InvalidArgumentException(\sprintf('The icon name "%s" is too long.', $name));
179179
}
180180
if ($curLength && ($maxLength < ($curLength + $nameLength + 1))) {
181181
yield $curBatch;

src/Icons/tests/Integration/Command/ImportIconCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testCanImportIcon(): void
4646
$this->executeConsoleCommand('ux:icons:import uiw:dashboard')
4747
->assertSuccessful()
4848
->assertOutputContains('Icon set: uiw icons (License: MIT)')
49-
->assertOutputContains("Importing uiw:dashboard")
49+
->assertOutputContains('Importing uiw:dashboard')
5050
;
5151

5252
$this->assertFileExists($expectedFile);

src/Icons/tests/Unit/IconifyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public function testChunkThrowWithIconPrefixTooLong(): void
298298
$prefix = str_pad('p', 101, 'p');
299299
$name = 'icon';
300300

301-
$this->expectExceptionMessage(sprintf('The icon prefix "%s" is too long.', $prefix));
301+
$this->expectExceptionMessage(\sprintf('The icon prefix "%s" is too long.', $prefix));
302302

303303
// We need to iterate over the iterator to trigger the exception
304304
$result = iterator_to_array($iconify->chunk($prefix, [$name]));
@@ -311,7 +311,7 @@ public function testChunkThrowWithIconNameTooLong(): void
311311
$prefix = 'prefix';
312312
$name = str_pad('n', 101, 'n');
313313

314-
$this->expectExceptionMessage(sprintf('The icon name "%s" is too long.', $name));
314+
$this->expectExceptionMessage(\sprintf('The icon name "%s" is too long.', $name));
315315

316316
// We need to iterate over the iterator to trigger the exception
317317
$result = iterator_to_array($iconify->chunk($prefix, [$name]));

0 commit comments

Comments
 (0)