public function generate(): string
    {
        // The tag name is required
        if ($this->getTag() === '') {
            return '';
        }

        // Generate the attribute string
        $tagAttributes = $this->generateTagAttributes();

        // When attributes are provided, add a space between the tag and the attributes
        $tagSeparator = '';
        if ($tagAttributes !== '') {
            $tagSeparator = ' ';
        }

        // Create the opening tag
        $openingTag = sprintf(
            '<%s%s%s>',
            $this->getTag(),
            $tagSeparator,
            $tagAttributes
        );

        // Create the closing tag
        $closingTag = '';
        if (! in_array($this->getTag(), self::SELF_CLOSING_TAGS)) {
            $closingTag = sprintf('</%s>', $this->getTag());
        }

        // Collect the tag information
        return $openingTag . $this->getText() . $closingTag;
    }