<?php

namespace AutoAdmin\Bundle\Content\Entity\Duplicators;

use AutoAdmin\Bundle\Content\Model\BrickInterface;

class BrickDuplicator extends AbstractDuplicator
{
    /**
     * @return string[]
     */
    public function support(): array
    {
        return [
            BrickInterface::class
        ];
    }

    /**
     * @param BrickInterface $entity
     * @param BrickInterface $duplicate
     *
     * @return BrickInterface
     */
    public function duplicate($entity, $duplicate, $parent = null)
    {
        $brick = $entity->getBrick();
        if ($brick !== null) {
            $newBrick = $this->builderService->replicate($brick);
            $duplicate->setBrick($newBrick);
        }

        return $duplicate;
    }
}