<?php

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

use stdClass;
use CouponsPlus\App\Coupon\Tree\Data\Transformers\Abilities\DataTransformerWithParent;
use CouponsPlus\App\Coupon\Tree\Data\Transformers\Abilities\TransformationStrategy;

class TransformerWithParentComposite implements DataTransformerWithParent
{
    private TransformerComposite $composite;
    private $parentData;

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

    public function setParentData($data)
    {
        $this->parentData = $data;
    }

    public function parentData(): ?stdClass
    {
        return $this->parentData;
    }

    /**
     * @param object $data
     * @return object
     */
    public function transform($data)
    {
        return $this->composite->transform($data);
    }
}
