<?php

declare (strict_types=1);
namespace Itdatex\Rechnungseingang\Vendor\JMS\Serializer\GraphNavigator\Factory;

use Itdatex\Rechnungseingang\Vendor\JMS\Serializer\Accessor\AccessorStrategyInterface;
use Itdatex\Rechnungseingang\Vendor\JMS\Serializer\Accessor\DefaultAccessorStrategy;
use Itdatex\Rechnungseingang\Vendor\JMS\Serializer\EventDispatcher\EventDispatcher;
use Itdatex\Rechnungseingang\Vendor\JMS\Serializer\EventDispatcher\EventDispatcherInterface;
use Itdatex\Rechnungseingang\Vendor\JMS\Serializer\Expression\ExpressionEvaluatorInterface;
use Itdatex\Rechnungseingang\Vendor\JMS\Serializer\GraphNavigator\SerializationGraphNavigator;
use Itdatex\Rechnungseingang\Vendor\JMS\Serializer\GraphNavigatorInterface;
use Itdatex\Rechnungseingang\Vendor\JMS\Serializer\Handler\HandlerRegistryInterface;
use Itdatex\Rechnungseingang\Vendor\Metadata\MetadataFactoryInterface;
final class SerializationGraphNavigatorFactory implements GraphNavigatorFactoryInterface
{
    /**
     * @var \MetadataFactoryInterface
     */
    private $metadataFactory;
    /**
     * @var HandlerRegistryInterface
     */
    private $handlerRegistry;
    /**
     * @var AccessorStrategyInterface
     */
    private $accessor;
    /**
     * @var EventDispatcherInterface
     */
    private $dispatcher;
    /**
     * @var ExpressionEvaluatorInterface
     */
    private $expressionEvaluator;
    public function __construct(MetadataFactoryInterface $metadataFactory, HandlerRegistryInterface $handlerRegistry, ?AccessorStrategyInterface $accessor = null, ?EventDispatcherInterface $dispatcher = null, ?ExpressionEvaluatorInterface $expressionEvaluator = null)
    {
        $this->metadataFactory = $metadataFactory;
        $this->handlerRegistry = $handlerRegistry;
        $this->accessor = $accessor ?: new DefaultAccessorStrategy();
        $this->dispatcher = $dispatcher ?: new EventDispatcher();
        $this->expressionEvaluator = $expressionEvaluator;
    }
    public function getGraphNavigator(): GraphNavigatorInterface
    {
        return new SerializationGraphNavigator($this->metadataFactory, $this->handlerRegistry, $this->accessor, $this->dispatcher, $this->expressionEvaluator);
    }
}