. */ namespace App\Services\LabelSystem\PlaceholderProviders; use App\Entity\Contracts\TimeStampableInterface; use IntlDateFormatter; use Locale; final class TimestampableElementProvider implements PlaceholderProviderInterface { public function replace(string $placeholder, object $label_target, array $options = []): ?string { if ($label_target instanceof TimeStampableInterface) { if ('[[LAST_MODIFIED]]' === $placeholder) { return IntlDateFormatter::formatObject($label_target->getLastModified() ?? new \DateTime(), IntlDateFormatter::SHORT, Locale::getDefault()); } if ('[[CREATION_DATE]]' === $placeholder) { return IntlDateFormatter::formatObject($label_target->getAddedDate() ?? new \DateTime(), IntlDateFormatter::SHORT, Locale::getDefault()); } } return null; } }