<?php

declare(strict_types=1);

namespace PpPhp\Plugins;

use PpPhp\Core\PluginSupport;
use PpPhp\Core\ViewPlugin;

class ShortDate implements ViewPlugin
{
    use PluginSupport;

    public static function id(): string { return 'ShortDate'; }
    public static function label(): string { return 'Short Date'; }
    public static function version(): string { return '1.1.0'; }
    public static function description(): string { return 'Displays a date in short numeric form (e.g. 01/05/2026), timezone-aware, with an optional custom format.'; }

    public static function render(mixed $value, array $settings): string
    {
        return self::formatDate($value, 'm/d/Y', $settings);
    }

    public static function settingsSchema(): array
    {
        return [['key' => 'format', 'type' => 'text', 'label' => 'Custom format', 'default' => '', 'hint' => 'Optional PHP date() format; blank = 01/05/2026.']];
    }

    public static function assets(): array { return ['js' => [], 'css' => []]; }
}
