Repository: symfony/ux
Pull request #2355 (2024-11-09 14:26:50)

[Site] fix typo on cookbook index
| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| Issues        | n/a
| License       | MIT

<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - For new features, provide some code snippets to help understand usage.
 - Features and deprecations must be submitted against branch main.
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->



Patch:
diff --git a/src/Icons/src/Iconify.php b/src/Icons/src/Iconify.php
index e29f2c69..757dacb2 100644
--- a/src/Icons/src/Iconify.php
+++ b/src/Icons/src/Iconify.php
@@ -85,54 +85,6 @@ final class Iconify
         ]);
     }
 
-    public function fetchIcons(string $prefix, array $names): array
-    {
-        if (!isset($this->sets()[$prefix])) {
-            throw new IconNotFoundException(\sprintf('The icon set "%s" does not exist on iconify.design.', $prefix));
-        }
-
-        // Sort to enforce cache hits
-        sort($names);
-        $queryString = implode(',', $names);
-        if (!preg_match('#^[a-z0-9-,]+$#', $queryString)) {
-            throw new \InvalidArgumentException('Invalid icon names.');
-        }
-
-        // URL must be 500 chars max (iconify limit)
-        // -39 chars: https://api.iconify.design/XXX.json?icons=
-        // -safe margin
-        if (450 < \strlen($prefix.$queryString)) {
-            throw new \InvalidArgumentException('The query string is too long.');
-        }
-
-        $response = $this->http->request('GET', \sprintf('/%s.json', $prefix), [
-            'headers' => [
-                'Accept' => 'application/json',
-            ],
-            'query' => [
-                'icons' => strtolower($queryString),
-            ],
-        ]);
-
-        if (200 !== $response->getStatusCode()) {
-            throw new IconNotFoundException(\sprintf('The icon set "%s" does not exist on iconify.design.', $prefix));
-        }
-
-        $data = $response->toArray();
-
-        $icons = [];
-        foreach ($data['icons'] as $iconName => $iconData) {
-            $height = $iconData['height'] ?? $data['height'] ??= $this->sets()[$prefix]['height'] ?? null;
-            $width = $iconData['width'] ?? $data['width'] ??= $this->sets()[$prefix]['width'] ?? null;
-
-            $icons[$iconName] = new Icon($iconData['body'], [
-                'viewBox' => \sprintf('0 0 %d %d', $width ?? $height, $height ?? $width),
-            ]);
-        }
-
-        return $icons;
-    }
-
     public function hasIconSet(string $prefix): bool
     {
         return isset($this->sets()[$prefix]);
diff --git a/ux.symfony.com/templates/cookbook/index.html.twig b/ux.symfony.com/templates/cookbook/index.html.twig
index 2a18a9f3..a15a4413 100644
--- a/ux.symfony.com/templates/cookbook/index.html.twig
+++ b/ux.symfony.com/templates/cookbook/index.html.twig
@@ -3,7 +3,7 @@
 {% set meta = {
     title: 'Cookbook',
     title_suffix: ' - Symfony UX',
-    description: 'Symfony UX cookbook - Concrete exeample to understantd all the concepts and components of Symfony UX',
+    description: 'Symfony UX Cookbook - Concrete examples to understantd all the concepts and components of Symfony UX.',
     canonical: url('app_cookbook'),
 } %}
 


Test patch:
diff --git a/src/Icons/tests/Unit/IconifyTest.php b/src/Icons/tests/Unit/IconifyTest.php
index 3fafce3a..b9406836 100644
--- a/src/Icons/tests/Unit/IconifyTest.php
+++ b/src/Icons/tests/Unit/IconifyTest.php
@@ -16,7 +16,6 @@ use Symfony\Component\Cache\Adapter\NullAdapter;
 use Symfony\Component\HttpClient\MockHttpClient;
 use Symfony\Component\HttpClient\Response\JsonMockResponse;
 use Symfony\UX\Icons\Exception\IconNotFoundException;
-use Symfony\UX\Icons\Icon;
 use Symfony\UX\Icons\Iconify;
 
 /**
@@ -163,71 +162,6 @@ class IconifyTest extends TestCase
         $iconify->fetchIcon('bi', 'heart');
     }
 
-    public function testFetchIcons(): void
-    {
-        $iconify = new Iconify(
-            cache: new NullAdapter(),
-            endpoint: 'https://example.com',
-            http: new MockHttpClient([
-                new JsonMockResponse([
-                    'bi' => [],
-                ]),
-                new JsonMockResponse([
-                    'icons' => [
-                        'heart' => [
-                            'body' => '<path d="M0 0h24v24H0z" fill="none"/>',
-                            'height' => 17,
-                        ],
-                        'bar' => [
-                            'body' => '<path d="M0 0h24v24H0z" fill="none"/>',
-                            'height' => 17,
-                        ],
-                    ],
-                ]),
-            ]),
-        );
-
-        $icons = $iconify->fetchIcons('bi', ['heart', 'bar']);
-
-        $this->assertCount(2, $icons);
-        $this->assertSame(['heart', 'bar'], array_keys($icons));
-        $this->assertContainsOnlyInstancesOf(Icon::class, $icons);
-    }
-
-    public function testFetchIconsThrowsWithInvalidIconNames(): void
-    {
-        $iconify = new Iconify(
-            cache: new NullAdapter(),
-            endpoint: 'https://example.com',
-            http: new MockHttpClient([
-                new JsonMockResponse([
-                    'bi' => [],
-                ]),
-            ]),
-        );
-
-        $this->expectException(\InvalidArgumentException::class);
-
-        $iconify->fetchIcons('bi', ['à', 'foo']);
-    }
-
-    public function testFetchIconsThrowsWithTooManyIcons(): void
-    {
-        $iconify = new Iconify(
-            cache: new NullAdapter(),
-            endpoint: 'https://example.com',
-            http: new MockHttpClient([
-                new JsonMockResponse([
-                    'bi' => [],
-                ]),
-            ]),
-        );
-
-        $this->expectException(\InvalidArgumentException::class);
-
-        $iconify->fetchIcons('bi', array_fill(0, 50, '1234567890'));
-    }
-
     public function testGetMetadata(): void
     {
         $responseFile = __DIR__.'/../Fixtures/Iconify/collections.json';