<?php declare(strict_types=1);

namespace Modules\Additional\Specifique\Client112\Modules\Facture\Service;

use Modules\Additional\Specifique\Client112\Modules\Facture\Repository\ParamSIContratFournisseurRepository;
use Psr\Container\ContainerInterface;

class SpecFactureDematMapper
{
    public static function initFactureDematMapper(
        object $config,
        ContainerInterface $container,
    ): object {

        /**
         * @var ParamSIContratFournisseurRepository
         */
        $paramSIContratFournisseurRepository = $container->get(ParamSIContratFournisseurRepository::class);
        $bt12NumFix                          = "Cs_{$paramSIContratFournisseurRepository->getBT12NumFix()}";

        // @phpstan-ignore-next-line
        $config
            ->FactEnt
            ->mapping
        ->{$bt12NumFix} = (object) [
                "xpath" => './cac:ContractDocumentReference/cbc:ID',
            ];

        return $config;
    }
}
