Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
47.37% covered (danger)
47.37%
9 / 19
CRAP
83.57% covered (warning)
83.57%
117 / 140
Serializer
0.00% covered (danger)
0.00%
0 / 1
47.37% covered (danger)
47.37%
9 / 19
66.93
83.57% covered (warning)
83.57%
117 / 140
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 getResult
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getRootNode
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getParentNode
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getLastChild
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 4
 startDocument
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 endDocument
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
10 / 10
 interpretPlacement
0.00% covered (danger)
0.00%
0 / 1
5.68
70.00% covered (warning)
70.00%
7 / 10
 characters
0.00% covered (danger)
0.00%
0 / 1
5.06
86.67% covered (warning)
86.67%
13 / 15
 insertElement
0.00% covered (danger)
0.00%
0 / 1
6.13
84.62% covered (warning)
84.62%
22 / 26
 endTag
0.00% covered (danger)
0.00%
0 / 1
5.03
90.00% covered (success)
90.00%
9 / 10
 serializeNode
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
10 / 10
 doctype
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 comment
0.00% covered (danger)
0.00%
0 / 1
5.58
71.43% covered (warning)
71.43%
10 / 14
 error
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 mergeAttributes
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 removeNode
0.00% covered (danger)
0.00%
0 / 1
3.02
87.50% covered (warning)
87.50%
7 / 8
 reparentChildren
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
11 / 11
 dump
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
<?php
namespace RemexHtml\Serializer;
use RemexHtml\PropGuard;
use RemexHtml\Tokenizer\Attributes;
use RemexHtml\Tokenizer\PlainAttributes;
use RemexHtml\TreeBuilder\Element;
use RemexHtml\TreeBuilder\TreeBuilder;
/**
 * A TreeHandler which builds a serialized representation of a document, by
 * encoding elements when the end tags are seen. This is faster than building
 * a DOM and then serializing it, even if you use DOMDocument::saveHTML().
 */
class Serializer implements AbstractSerializer {
    use PropGuard;
    /**
     * A node corresponding to the Document
     * @var SerializerNode
     */
    private $root;
    /**
     * The error callback
     */
    private $errorCallback;
    /**
     * The Formatter implementation
     *
     * @var Formatter
     */
    private $formatter;
    /**
     * All active SerializerNode objects in an array, so that they can be
     * referred to by integer indexes. This is a way to emulate weak references,
     * to avoid circular references, allowing nodes to be freed.
     *
     * @var SerializerNode[]
     * @internal
     */
    protected $nodes = [];
    /**
     * True if we are parsing a fragment. The children of the <html> element
     * will be serialized, instead of the whole document.
     */
    private $isFragment;
    /**
     * The result string
     */
    private $result = '';
    /**
     * Constructor
     *
     * @param Formatter $formatter
     * @param callable|null $errorCallback A function which is called with the
     *   details of each parse error
     */
    public function __construct( Formatter $formatter, $errorCallback = null ) {
        $this->formatter = $formatter;
        $this->errorCallback = $errorCallback;