Skip to content

Commit

Permalink
use serializer interface as contract instead of actual implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sweikenb committed Jul 10, 2024
1 parent f9c2f1c commit f5ebeaf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Service/NormalizerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;

class NormalizerService
{
private readonly Factory $factory;
private readonly Serializer $serializer;

public function __construct(?Factory $factory = null, ?Serializer $serializer = null)
public function __construct(?Factory $factory = null, ?SerializerInterface $serializer = null)
{
$this->factory = $factory ?? new Factory();
$this->serializer = $serializer ?? new Serializer([new ObjectNormalizer()], [new JsonEncoder()]);
Expand Down

0 comments on commit f5ebeaf

Please sign in to comment.