Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
WrapSections
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 run
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\Parsoid\Wt2Html\DOM\Processors;
5
6use Wikimedia\Parsoid\Config\Env;
7use Wikimedia\Parsoid\DOM\Node;
8use Wikimedia\Parsoid\Wt2Html\Wt2HtmlDOMProcessor;
9
10class WrapSections implements Wt2HtmlDOMProcessor {
11
12    /**
13     * DOM Postprocessor entry function to walk DOM rooted at $root
14     * and add <section> wrappers as necessary.
15     * Implements the algorithm documented @ mw:Parsing/Notes/Section_Wrapping
16     *
17     * @inheritDoc
18     */
19    public function run(
20        Env $env, Node $root, array $options = [], bool $atTopLevel = false
21    ): void {
22        if ( !$env->getWrapSections() ) {
23            return;
24        }
25
26        $state = new WrapSectionsState(
27            $env,
28            $options['frame'],
29            $root
30        );
31        $state->run();
32    }
33}