<?php

namespace AutoAdmin\Bundle\Content\Duplicator;

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

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

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

        return $duplicate;
    }
}
