<?php
    declare(strict_types=1);

    namespace Icing\View\Helper;

    /**
     * Html helper
     */
    class HtmlHelper extends \BootstrapUI\View\Helper\HtmlHelper
    {

        public function i(string $class, $options = []): string
        {
            $options['class'] = $class . ' ' . ($options['class'] ?? '');
            $options['escape'] ??= false;
            return $this->tag('i', '', $options);
        }

        public function tag(string $name, ?string $text = null, array $options = []): string
        {
            $options += ['escape' => false];
            return parent::tag($name, $text, $options);
        }

        public function link(array|string $title = null, $url = null, array $options = []): string
        {
            if ($title === null) {
                return '';
            }
            $options += ['escape' => false];
            return parent::link($title, $url, $options);
        }

        /* public function __call(string $method, array $params)
         {

             $text = $params[0];
             unset($params[0]);

             return $this->tag($method, $text, ...$params);
         }*/

        public function checkmark(mixed $check = false, string $onTrue = null, $onFalse = null, $options = []): string
        {
            $onTrue  = $onTrue ?? 'fa-solid fa-check text-success';
            $onFalse = $onFalse ?? 'fa-solid fa-close text-danger';
            if ($check) {
                $options['class'] = ($options['class'] ?? '') . " $onTrue";
            } else {
                $options['class'] = ($options['class'] ?? '') . " $onFalse";
            }
            return $this->tag('i', '', $options);
        }


    }
