Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 14
CRAP
0.00% covered (danger)
0.00%
0 / 52
SerializerWithTracer
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 14
380
0.00% covered (danger)
0.00%
0 / 52
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 6
 handle
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 6
 trace
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 startDocument
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 endDocument
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 14
 characters
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 insertElement
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 endTag
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 doctype
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 comment
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 error
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 mergeAttributes
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 removeNode
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 reparentChildren
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
<?php
namespace RemexHtml\Serializer;
use RemexHtml\Tokenizer\Attributes;
use RemexHtml\TreeBuilder\Element;
use RemexHtml\TreeBuilder\TraceFormatter;
class SerializerWithTracer extends Serializer {
    private $traceCallback;
    private $verbosity;
    public function __construct( Formatter $formatter, $errorCallback = null, $traceCallback = null,
        $verbosity = 0
    ) {
        $this->traceCallback = $traceCallback;
        $this->verbosity = $verbosity;
        parent::__construct( $formatter, $errorCallback );
    }
    private function handle( $funcName, $args ) {
        $this->trace( call_user_func_array( [ TraceFormatter::class, $funcName ], $args ) );
        call_user_func_array( [ parent::class, $funcName ], $args );
        if ( $this->verbosity > 0 && $funcName !== 'endDocument' ) {
            $this->trace( "Dump after $funcName" . $this->dump() );
        }
    }
    private function trace( $msg ) {
        call_user_func( $this->traceCallback, "[Serializer] $msg" );
    }
    public function startDocument( $fragmentNamespace, $fragmentName ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function endDocument( $pos ) {
        if ( count( $this->nodes ) ) {
            $nodeTags = '';
            foreach ( $this->nodes as $node ) {
                if ( $nodeTags !== '' ) {
                    $nodeTags .= ', ';
                }
                $nodeTags .= $node->getDebugTag();
            }
            $this->trace( "endDocument: unclosed elements: $nodeTags" );
        } else {
            $this->trace( "endDocument: no unclosed elements" );
        }
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function characters( $preposition, $refElement, $text, $start, $length,
        $sourceStart, $sourceLength
    ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function insertElement( $preposition, $refElement, Element $element, $void,
        $sourceStart, $sourceLength
    ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function endTag( Element $element, $sourceStart, $sourceLength ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function comment( $preposition, $refElement, $text, $sourceStart, $sourceLength ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function error( $text, $pos ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function mergeAttributes( Element $element, Attributes $attrs, $sourceStart ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function removeNode( Element $element, $sourceStart ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
    public function reparentChildren( Element $element, Element $newParent, $sourceStart ) {
        $this->handle( __FUNCTION__, func_get_args() );
    }
}