<?php

namespace CouponsPlus\App\Coupon\Tree\Data\Transformers;

use CouponsPlus\Original\Collections\Collection;
use CouponsPlus\App\Coupon\Tree\Data\Transformers\Abilities\DataTransformer;
use CouponsPlus\App\Coupon\Tree\Data\Transformers\Abilities\TransformationStrategy;

class TransformerComposite implements DataTransformer
{
    private Collection $transformers;
    private TransformationStrategy $strategy;

    public function __construct(array $transformers, TransformationStrategy $strategy)
    {
        $this->transformers = new Collection($transformers);
        $this->strategy = $strategy;
    }

    /**
     * @param object $data
     * @return object
     */
    public function transform($data): object
    {
        return $this->strategy->execute($this->transformers, $data);
    }
}
