<?php
namespace PpPhp\Plugins;
use PpPhp\Core\ViewPlugin;

class Currency implements ViewPlugin
{
    public static function id(): string { return 'Currency'; }
    public static function label(): string { return 'Currency'; }
    public static function version(): string { return '1.0.0'; }
    public static function description(): string { return 'Formats a number as currency with symbol and decimals.'; }
    public static function render(mixed $value, array $settings): string {
        $symbol = $settings['symbol'] ?? '$';
        $decimals = (int)($settings['decimals'] ?? 2);
        return htmlspecialchars($symbol . number_format((float)$value, $decimals));
    }
    public static function settingsSchema(): array {
        return [
            ['key'=>'symbol',   'type'=>'text',   'label'=>'Symbol',   'default'=>'$'],
            ['key'=>'decimals', 'type'=>'number', 'label'=>'Decimal Places', 'default'=>2],
        ];
    }
    public static function assets(): array { return ['js'=>[], 'css'=>[]]; }
}