. */ 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) { $formatter = new IntlDateFormatter(Locale::getDefault(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); if ('[[LAST_MODIFIED]]' === $placeholder) { return $formatter->format($label_target->getLastModified() ?? new \DateTime()); } if ('[[CREATION_DATE]]' === $placeholder) { return $formatter->format($label_target->getAddedDate() ?? new \DateTime()); } } return null; } }