Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
SingleLineContext
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
5
100.00% covered (success)
100.00%
1 / 1
 enforce
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 enforced
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 disable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 pop
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\Parsoid\Html2Wt;
5
6/**
7 * Stack and helpers to enforce single-line context while serializing.
8 */
9class SingleLineContext {
10    // PORT-TODO document
11
12    private array $stack = [];
13
14    public function enforce(): void {
15        $this->stack[] = true;
16    }
17
18    public function enforced(): bool {
19        return count( $this->stack ) > 0 && end( $this->stack );
20    }
21
22    public function disable(): void {
23        $this->stack[] = false;
24    }
25
26    public function pop(): void {
27        array_pop( $this->stack );
28    }
29
30}