<?php

namespace AutoAdmin\Bundle\Content\Duplicator;

use AutoAdmin\Bundle\Content\Duplicator\Enum\StringDuplicateModeEnum;
use AutoAdmin\Bundle\Content\Model\TitleInterface;

/**
 * @deprecated {@see SeoContentTranslationDuplicator} or {@see NameDuplicator}
 */
class TitleDuplicator extends AbstractDuplicator
{
    /**
     * @return string[]
     */
    public function supportInterfaces(): array
    {
        return [
            TitleInterface::class,
        ];
    }

    /**
     * @param TitleInterface $entity
     * @param TitleInterface $duplicate
     *
     * @return TitleInterface
     */
    public function duplicate(object $entity, object $duplicate): object
    {
        if (method_exists($duplicate, 'setTitle')) {
            $duplicate->setTitle($this->suffixes->duplicate($entity->getTitle(), StringDuplicateModeEnum::LABEL));
        }

        return $duplicate;
    }
}
