Skip to content

Commit

Permalink
feat: add symfony serializer facade
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed Jun 18, 2024
1 parent 68ca905 commit b0d0c04
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
<code><![CDATA[it_gets_manager_from_facade]]></code>
</PossiblyUnusedMethod>
</file>
<file src="tests/src/Functional/Bridge/Laravel/Facades/SerializerTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[it_gets_symfony_serializer_from_facade]]></code>
</PossiblyUnusedMethod>
</file>
<file src="tests/src/Functional/Bridge/Laravel/Http/ResponseFactoryTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[it_creates_from_array_iterator]]></code>
Expand Down
15 changes: 15 additions & 0 deletions src/Bridge/Laravel/Facades/Serializer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace WayOfDev\Serializer\Bridge\Laravel\Facades;

use Illuminate\Support\Facades\Facade;

class Serializer extends Facade
{
protected static function getFacadeAccessor(): string
{
return 'symfony.serializer';
}
}
1 change: 1 addition & 0 deletions src/Bridge/Laravel/Providers/SerializerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ private function registerSymfonySerializer(): void
});

$this->app->singleton(SymfonySerializer::class, SymfonySerializerInterface::class);
$this->app->alias(SymfonySerializerInterface::class, 'symfony.serializer');
}

private function registerSerializerManager(): void
Expand Down
22 changes: 22 additions & 0 deletions tests/src/Functional/Bridge/Laravel/Facades/SerializerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace WayOfDev\Tests\Functional\Bridge\Laravel\Facades;

use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\Serializer\SerializerInterface as SymfonySerializerInterface;
use WayOfDev\Serializer\Bridge\Laravel\Facades\Serializer;
use WayOfDev\Tests\Functional\TestCase;

final class SerializerTest extends TestCase
{
#[Test]
public function it_gets_symfony_serializer_from_facade(): void
{
$serializer = Serializer::getFacadeRoot();

self::assertNotNull($serializer);
self::assertInstanceOf(SymfonySerializerInterface::class, $serializer);
}
}

0 comments on commit b0d0c04

Please sign in to comment.