src/HtmlElement.php
public static function htmlTag(string $tag, array $attributes = [], array $props = [], $innerHtml = null) : string
    {
        $invalid = $tag[0] != '<' || substr($tag, -1) != '>';

        if (substr($tag, -2) == '/>') {
            $control = trim(substr($tag, 0, -2));
        } else {
            $control = $tag;
        }

        $invalid = $invalid ? $invalid : strpos($control, ' ') !== false;

        if ($invalid) {
            throw new \InvalidArgumentException(sprintf("Please provide a valid tag format, '%s' given", $tag));
        }

        $autoClose = (substr($tag, -2) == '/>');

        $return = ($autoClose) ? trim(substr($tag, 0, -2)) : trim(substr($tag, 0, -1));
        $return .= ' ' . self::htmlAttribute($attributes);
        $return .= ' ' . implode(' ', $props);
        $return = trim($return);

        if ($autoClose) {
            $return .= ' />';
        } else {
            $return .= '>';
            if (!is_null($innerHtml)) {
                $return .= $innerHtml;
            }

            $return .= '</' . substr($tag, 1);
        }

        return $return;
    }
public static function htmlTag(string $tag, array $attributes = [], array $props = [], $innerHtml = null) : string
    {
        $invalid = $tag[0] != '<' || substr($tag, -1) != '>';

        if (substr($tag, -2) == '/>') {
            $control = trim(substr($tag, 0, -2));
        } else {
            $control = $tag;
        }

        $invalid = $invalid ? $invalid : strpos($control, ' ') !== false;

        if ($invalid) {
            throw new \InvalidArgumentException(sprintf("Please provide a valid tag format, '%s' given", $tag));
        }

        $autoClose = (substr($tag, -2) == '/>');

        $return = ($autoClose) ? trim(substr($tag, 0, -2)) : trim(substr($tag, 0, -1));
        $return .= ' ' . self::htmlAttribute($attributes);
        $return .= ' ' . implode(' ', $props);
        $return = trim($return);

        if ($autoClose) {
            $return .= ' />';
        } else {
            $return .= '>';
            if (!is_null($innerHtml)) {
                $return .= $innerHtml;
            }

            $return .= '</' . substr($tag, 1);
        }

        return $return;
    }
@param string $tag
@param array $attributes
@param array $props
@param string $innerHtml

@throws \InvalidArgumentException

@return string