<?php

namespace CouponsPlus\App\Coupon\Tree\Finders;

use CouponsPlus\App\Coupon\Tree\Factories\DataStructureFromJSONFactory;
use CouponsPlus\App\Coupon\Tree\Factories\TestableGroupDataFromStandardObjectFactory;
use CouponsPlus\App\Coupon\Tree\Data\Transformers\PartialTestableMergerTransformerFromRelations;

class ProductionDataStructureFromJSONFactory
{
    public function create(string $partialRelationsSource) : DataStructureFromJSONFactory
    {
        return new DataStructureFromJSONFactory(
            new TestableGroupDataFromStandardObjectFactory,
            new PartialTestableMergerTransformerFromRelations(new TestablePartialRelationsDataFinderFromCollection(
                json_decode($partialRelationsSource, false, 512, JSON_THROW_ON_ERROR)
            ))
        );
    }
}