From b8930e4da0b65c005a07745e523cb99236313bbe Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Wed, 27 Mar 2024 12:28:41 -0400 Subject: [PATCH] [Icons] `Icon` changes --- src/Icons/src/{Svg => }/Icon.php | 14 ++------------ src/Icons/src/IconCacheWarmer.php | 1 - src/Icons/src/IconRegistryInterface.php | 1 - src/Icons/src/Iconify.php | 1 - src/Icons/src/Registry/CacheIconRegistry.php | 2 +- src/Icons/src/Registry/ChainIconRegistry.php | 2 +- src/Icons/src/Registry/IconifyOnDemandRegistry.php | 2 +- src/Icons/src/Registry/LocalSvgIconRegistry.php | 2 +- src/Icons/tests/Unit/IconRendererTest.php | 2 +- src/Icons/tests/Unit/{Svg => }/IconTest.php | 11 +++++++++-- .../Unit/Registry/InMemoryIconRegistryTest.php | 2 +- .../Unit/Registry/LocalSvgIconRegistryTest.php | 2 +- src/Icons/tests/Util/InMemoryIconRegistry.php | 2 +- 13 files changed, 19 insertions(+), 25 deletions(-) rename src/Icons/src/{Svg => }/Icon.php (94%) rename src/Icons/tests/Unit/{Svg => }/IconTest.php (96%) diff --git a/src/Icons/src/Svg/Icon.php b/src/Icons/src/Icon.php similarity index 94% rename from src/Icons/src/Svg/Icon.php rename to src/Icons/src/Icon.php index 9a4803a491c..29fb941d36a 100644 --- a/src/Icons/src/Svg/Icon.php +++ b/src/Icons/src/Icon.php @@ -9,14 +9,14 @@ * file that was distributed with this source code. */ -namespace Symfony\UX\Icons\Svg; +namespace Symfony\UX\Icons; /** * @author Simon André * * @internal */ -final class Icon implements \Stringable, \Serializable +final class Icon implements \Stringable { /** * Transforms a valid icon ID into an icon name. @@ -193,16 +193,6 @@ public function __toString(): string return $this->toHtml(); } - public function serialize(): string - { - return serialize([$this->innerSvg, $this->attributes]); - } - - public function unserialize(string $data): void - { - [$this->innerSvg, $this->attributes] = unserialize($data); - } - public function __serialize(): array { return [$this->innerSvg, $this->attributes]; diff --git a/src/Icons/src/IconCacheWarmer.php b/src/Icons/src/IconCacheWarmer.php index 6885ded79fd..04215ae713f 100644 --- a/src/Icons/src/IconCacheWarmer.php +++ b/src/Icons/src/IconCacheWarmer.php @@ -13,7 +13,6 @@ use Symfony\UX\Icons\Exception\IconNotFoundException; use Symfony\UX\Icons\Registry\CacheIconRegistry; -use Symfony\UX\Icons\Svg\Icon; use Symfony\UX\Icons\Twig\IconFinder; /** diff --git a/src/Icons/src/IconRegistryInterface.php b/src/Icons/src/IconRegistryInterface.php index ad26d37de91..29d845970a0 100644 --- a/src/Icons/src/IconRegistryInterface.php +++ b/src/Icons/src/IconRegistryInterface.php @@ -12,7 +12,6 @@ namespace Symfony\UX\Icons; use Symfony\UX\Icons\Exception\IconNotFoundException; -use Symfony\UX\Icons\Svg\Icon; /** * @author Kevin Bond diff --git a/src/Icons/src/Iconify.php b/src/Icons/src/Iconify.php index f5317f3c956..41d5617606d 100644 --- a/src/Icons/src/Iconify.php +++ b/src/Icons/src/Iconify.php @@ -17,7 +17,6 @@ use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\UX\Icons\Exception\IconNotFoundException; -use Symfony\UX\Icons\Svg\Icon; /** * @author Kevin Bond diff --git a/src/Icons/src/Registry/CacheIconRegistry.php b/src/Icons/src/Registry/CacheIconRegistry.php index 0530ce16f0c..1ab4733f1db 100644 --- a/src/Icons/src/Registry/CacheIconRegistry.php +++ b/src/Icons/src/Registry/CacheIconRegistry.php @@ -13,8 +13,8 @@ use Symfony\Contracts\Cache\CacheInterface; use Symfony\UX\Icons\Exception\IconNotFoundException; +use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\IconRegistryInterface; -use Symfony\UX\Icons\Svg\Icon; /** * @author Kevin Bond diff --git a/src/Icons/src/Registry/ChainIconRegistry.php b/src/Icons/src/Registry/ChainIconRegistry.php index c66e9bbe0b7..e9c4c31201d 100644 --- a/src/Icons/src/Registry/ChainIconRegistry.php +++ b/src/Icons/src/Registry/ChainIconRegistry.php @@ -12,8 +12,8 @@ namespace Symfony\UX\Icons\Registry; use Symfony\UX\Icons\Exception\IconNotFoundException; +use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\IconRegistryInterface; -use Symfony\UX\Icons\Svg\Icon; /** * @author Kevin Bond diff --git a/src/Icons/src/Registry/IconifyOnDemandRegistry.php b/src/Icons/src/Registry/IconifyOnDemandRegistry.php index 88b6fcca386..4c314ca79d1 100644 --- a/src/Icons/src/Registry/IconifyOnDemandRegistry.php +++ b/src/Icons/src/Registry/IconifyOnDemandRegistry.php @@ -12,9 +12,9 @@ namespace Symfony\UX\Icons\Registry; use Symfony\UX\Icons\Exception\IconNotFoundException; +use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\Iconify; use Symfony\UX\Icons\IconRegistryInterface; -use Symfony\UX\Icons\Svg\Icon; /** * @author Kevin Bond diff --git a/src/Icons/src/Registry/LocalSvgIconRegistry.php b/src/Icons/src/Registry/LocalSvgIconRegistry.php index e76818bdc35..9b6ad613523 100644 --- a/src/Icons/src/Registry/LocalSvgIconRegistry.php +++ b/src/Icons/src/Registry/LocalSvgIconRegistry.php @@ -13,8 +13,8 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\UX\Icons\Exception\IconNotFoundException; +use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\IconRegistryInterface; -use Symfony\UX\Icons\Svg\Icon; /** * @author Kevin Bond diff --git a/src/Icons/tests/Unit/IconRendererTest.php b/src/Icons/tests/Unit/IconRendererTest.php index 3fcfc937e6a..4fa31e407a2 100644 --- a/src/Icons/tests/Unit/IconRendererTest.php +++ b/src/Icons/tests/Unit/IconRendererTest.php @@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase; use Symfony\UX\Icons\Exception\IconNotFoundException; +use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\IconRegistryInterface; use Symfony\UX\Icons\IconRenderer; -use Symfony\UX\Icons\Svg\Icon; use Symfony\UX\Icons\Tests\Util\InMemoryIconRegistry; /** diff --git a/src/Icons/tests/Unit/Svg/IconTest.php b/src/Icons/tests/Unit/IconTest.php similarity index 96% rename from src/Icons/tests/Unit/Svg/IconTest.php rename to src/Icons/tests/Unit/IconTest.php index 5bbb7bf1f4a..38e97a20db3 100644 --- a/src/Icons/tests/Unit/Svg/IconTest.php +++ b/src/Icons/tests/Unit/IconTest.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Symfony\UX\Icons\Tests\Unit\Svg; +namespace Symfony\UX\Icons\Tests\Unit; use PHPUnit\Framework\TestCase; -use Symfony\UX\Icons\Svg\Icon; +use Symfony\UX\Icons\Icon; final class IconTest extends TestCase { @@ -275,4 +275,11 @@ public static function provideWithAttributesTestCases(): iterable ['foo' => 'foobar', 'baz' => 'qux'], ]; } + + public function testSerialize(): void + { + $icon = new Icon('foo', ['bar' => 'baz']); + + $this->assertEquals($icon, unserialize(serialize($icon))); + } } diff --git a/src/Icons/tests/Unit/Registry/InMemoryIconRegistryTest.php b/src/Icons/tests/Unit/Registry/InMemoryIconRegistryTest.php index 08e110b227f..0d0e87b8c81 100644 --- a/src/Icons/tests/Unit/Registry/InMemoryIconRegistryTest.php +++ b/src/Icons/tests/Unit/Registry/InMemoryIconRegistryTest.php @@ -13,7 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\UX\Icons\Exception\IconNotFoundException; -use Symfony\UX\Icons\Svg\Icon; +use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\Tests\Util\InMemoryIconRegistry; /** diff --git a/src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php b/src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php index 81d5184507e..4cef5927cfc 100644 --- a/src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php +++ b/src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php @@ -12,8 +12,8 @@ namespace Symfony\UX\Icons\Tests\Unit\Registry; use PHPUnit\Framework\TestCase; +use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\Registry\LocalSvgIconRegistry; -use Symfony\UX\Icons\Svg\Icon; /** * @author Kevin Bond diff --git a/src/Icons/tests/Util/InMemoryIconRegistry.php b/src/Icons/tests/Util/InMemoryIconRegistry.php index 359118b8f85..d472a9cfef1 100644 --- a/src/Icons/tests/Util/InMemoryIconRegistry.php +++ b/src/Icons/tests/Util/InMemoryIconRegistry.php @@ -12,8 +12,8 @@ namespace Symfony\UX\Icons\Tests\Util; use Symfony\UX\Icons\Exception\IconNotFoundException; +use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\IconRegistryInterface; -use Symfony\UX\Icons\Svg\Icon; /** * @author Simon André