Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
33.33% covered (danger)
33.33%
1 / 3
33.33% covered (danger)
33.33%
1 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ParserOptions
33.33% covered (danger)
33.33%
1 / 3
33.33% covered (danger)
33.33%
1 / 3
5.67
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 withScriptingEnabled
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 withAssumedEncoding
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Html;
6
7/**
8 * Optional knobs for {@see Parser}. Defaults match the most common
9 * print/render use case: scripts off, encoding auto-detected.
10 */
11final readonly class ParserOptions
12{
13    public function __construct(
14        /**
15         * Affects <noscript> handling per WHATWG. When false (default), the
16         * contents of <noscript> are parsed normally; when true, the entire
17         * <noscript> body becomes a single text node.
18         */
19        public bool $scriptingEnabled = false,
20        /**
21         * Override BOM/meta charset detection. When null (default), the
22         * tokenizer follows the WHATWG encoding-sniffing algorithm.
23         */
24        public ?string $assumedEncoding = null,
25    ) {}
26
27    public function withScriptingEnabled(bool $enabled): self
28    {
29        return new self(scriptingEnabled: $enabled, assumedEncoding: $this->assumedEncoding);
30    }
31
32    public function withAssumedEncoding(?string $encoding): self
33    {
34        return new self(scriptingEnabled: $this->scriptingEnabled, assumedEncoding: $encoding);
35    }
36}