<?php

namespace AutoAdmin\Bundle\Content\Entity\Duplicators;

use AutoAdmin\Bundle\Content\Entity\Interfaces\MenuInterface;

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

    /**
     * @param MenuInterface $entity
     * @param MenuInterface $duplicate
     *
     * @return MenuInterface
     */
    public function duplicate($entity, $duplicate, $parent = null)
    {
        if ($entity->getRoot() !== null) {
            $duplicate->setRoot($this->duplicatorService->duplicate($entity->getRoot(), $duplicate));
        }

        return $duplicate;
    }
}
