Completed
Push — master ( 40af63...ba54cf )
by Josh
03:58
created

RenameLivePreviewEvent   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalizeAttribute() 0 3 1
A normalizeElement() 0 5 1
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2019 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 DOMAttr;
11
use DOMElement;
12
13
/**
14
* Rename deprecated data-s9e-livepreview-postprocess attributes to data-s9e-livepreview-onrender
15
*/
16
class RenameLivePreviewEvent extends AbstractNormalization
17
{
18
	/**
19
	* {@inheritdoc}
20
	*/
21
	protected $queries = [
22
		'//*[@data-s9e-livepreview-postprocess]',
23
		'//xsl:attribute/@name[. = "data-s9e-livepreview-postprocess"]'
24
	];
25
26
	/**
27
	* {@inheritdoc}
28
	*/
29 1
	protected function normalizeAttribute(DOMAttr $attribute)
30
	{
31 1
		$attribute->value = 'data-s9e-livepreview-onrender';
32
	}
33
34
	/**
35
	* {@inheritdoc}
36
	*/
37 1
	protected function normalizeElement(DOMElement $element)
38
	{
39 1
		$value = $element->getAttribute('data-s9e-livepreview-postprocess');
40 1
		$element->setAttribute('data-s9e-livepreview-onrender', $value);
41 1
		$element->removeAttribute('data-s9e-livepreview-postprocess');
42
	}
43
}