<?php

namespace NoahVet\Reef\Infrastructure\Serialization\Jane;

use NoahVet\Reef\Domain\Serialization\Jane\JaneNormalizerInterface as SelfInterface;
use NoahVet\Reef\Domain\Serialization\Json\JsonSerializerFacadeInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

class JaneNormalizer implements SelfInterface
{
    /**
     * @param list<DenormalizerInterface&NormalizerInterface> $janeObjectNormalizers
     */
    public function __construct(
        protected readonly JsonSerializerFacadeInterface $serializer,
        protected readonly array $janeObjectNormalizers = [],
    ) {
    }

    /**
     * @return array<string, mixed>
     */
    #[\Override]
    public function normalize(object $object): array
    {
        return (array) $this->serializer->normalize(
            data: $object,
            normalizers: $this->janeObjectNormalizers,
        );
    }
}
