Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
33.33% covered (danger)
33.33%
2 / 6
CRAP
66.67% covered (warning)
66.67%
12 / 18
FastFormatter
0.00% covered (danger)
0.00%
0 / 1
33.33% covered (danger)
33.33%
2 / 6
17.33
66.67% covered (warning)
66.67%
12 / 18
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 startDocument
0.00% covered (danger)
0.00%
0 / 1
2.15
66.67% covered (warning)
66.67%
2 / 3
 doctype
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 characters
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 element
0.00% covered (danger)
0.00%
0 / 1
6.73
72.73% covered (warning)
72.73%
8 / 11
 comment
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
namespace RemexHtml\Serializer;
/**
 * A formatter suitable for pre-sanitized input with ignoreEntities enabled
 * in the Tokenizer.
 */
class FastFormatter implements Formatter {
    public function __construct( $options = [] ) {
    }
    /**
     * @inheritDoc
     */
    public function startDocument( $fragmentNamespace, $fragmentName ) {
        if ( $fragmentNamespace === null ) {
            return "<!DOCTYPE html>\n";
        } else {
            return '';
        }
    }
    /**
     * @inheritDoc
     */
    public function doctype( $name, $public, $system ) {
        return '';
    }
    /**
     * @inheritDoc
     */
    public function characters( SerializerNode $parent, $text, $start, $length ) {
        return substr( $text, $start, $length );
    }
    /**
     * @inheritDoc
     */
    public function element( SerializerNode $parent, SerializerNode $node, $contents ) {
        $name = $node->name;
        $ret = "<$name";
        foreach ( $node->attrs->getValues() as $attrName => $value ) {
            $ret .= " $attrName=\"$value\"";
        }
        if ( $contents === null ) {
            $ret .= "/>";
        } elseif ( isset( $contents[0] ) && $contents[0] === "\n"
            && in_array( $name, [ 'pre', 'textarea', 'listing' ] )
        ) {
            $ret .= ">\n$contents</$name>";
        } else {
            $ret .= ">$contents</$name>";
        }
        return $ret;
    }
    /**
     * @inheritDoc
     */
    public function comment( SerializerNode $parent, $text ) {
        return "<!--$text-->";
    }
}