Passed
Branch major/TemplateNormalizationsSw... (c391a8)
by Josh
02:38
created

PreserveSingleSpaces::normalizeText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2023 The s9e authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Configurator\TemplateNormalizations;
9
10
use DOMText;
11
12
/**
13
* Remove all inter-element whitespace except for single space characters
14
*/
15
class PreserveSingleSpaces extends AbstractNormalization
16
{
17
	/**
18
	* {@inheritdoc}
19
	*/
20
	protected array $queries = ['//text()[. = " "][not(parent::xsl:text)]'];
21
22
	/**
23
	* {@inheritdoc}
24
	*/
25
	protected function normalizeText(DOMText $node)
26
	{
27
		$node->replaceWith($this->ownerDocument->createXslText(' '));
28
	}
29
}