public function compileToken(array $token): string
    {
        if (in_array($token[self::TOKEN_TYPE], [self::PLAIN_TEXT, self::TAG_CLOSE])) {
            //Nothing to compile
            return $token[HtmlTokenizer::TOKEN_CONTENT];
        }

        $result = $token[HtmlTokenizer::TOKEN_NAME];
        $attributes = [];
        foreach ($token[self::TOKEN_ATTRIBUTES] as $attribute => $value) {
            if ($value === null) {
                $attributes[] = $attribute;
                continue;
            }

            $attributes[] = $attribute . '="' . $value . '"';
        }

        if (!empty($attributes)) {
            $result .= ' ' . join(' ', $attributes);
        }

        if ($token[HtmlTokenizer::TOKEN_TYPE] == HtmlTokenizer::TAG_SHORT) {
            $result .= '/';
        }

        return '<' . $result . '>';
    }
public function compileToken(array $token): string
    {
        if (in_array($token[self::TOKEN_TYPE], [self::PLAIN_TEXT, self::TAG_CLOSE])) {
            //Nothing to compile
            return $token[HtmlTokenizer::TOKEN_CONTENT];
        }

        $result = $token[HtmlTokenizer::TOKEN_NAME];
        $attributes = [];
        foreach ($token[self::TOKEN_ATTRIBUTES] as $attribute => $value) {
            if ($value === null) {
                $attributes[] = $attribute;
                continue;
            }

            $attributes[] = $attribute . '="' . $value . '"';
        }

        if (!empty($attributes)) {
            $result .= ' ' . join(' ', $attributes);
        }

        if ($token[HtmlTokenizer::TOKEN_TYPE] == HtmlTokenizer::TAG_SHORT) {
            $result .= '/';
        }

        return '<' . $result . '>';
    }
public function compileToken ( array $ token ) : string { if ( in_array ( $ token [ self :: TOKEN_TYPE ] , [ self :: PLAIN_TEXT , self :: TAG_CLOSE ] ) ) { //Nothing to compile return $ token [ HtmlTokenizer :: TOKEN_CONTENT ] ; } $ result = $ token [ HtmlTokenizer :: TOKEN_NAME ] ; $ attributes = [ ] ; foreach ( $ token [ self :: TOKEN_ATTRIBUTES ] as $ attribute => $ value ) { if ( $ value === null ) { $ attributes [ ] = $ attribute ; continue ; } $ attributes [ ] = $ attribute . '="' . $ value . '"' ; } if ( ! empty ( $ attributes ) ) { $ result .= ' ' . join ( ' ' , $ attributes ) ; } if ( $ token [ HtmlTokenizer :: TOKEN_TYPE ] == HtmlTokenizer :: TAG_SHORT ) { $ result .= '/' ; } return '<' . $ result . '>' ; }
Compile parsed token.

@param array $token

@return string
Compile parsed token .