Completed
Push — master ( 83ef6e...8aef6f )
by Josh
64:04 queued 30:49
created

RemoveLivePreviewAttributes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalizeAttribute() 0 4 1
A normalizeElement() 0 4 1
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2016 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
* Remove attributes related to live preview
15
*/
16
class RemoveLivePreviewAttributes extends AbstractNormalization
17
{
18
	/**
19
	* {@inheritdoc}
20
	*/
21
	protected $queries = [
22
		'//@*           [starts-with(name(), "data-s9e-livepreview-")]',
23
		'//xsl:attribute[starts-with(@name,  "data-s9e-livepreview-")]'
24
	];
25
26
	/**
27
	* {@inheritdoc}
28
	*/
29
	protected function normalizeAttribute(DOMAttr $attribute)
30
	{
31
		$attribute->parentNode->removeAttributeNode($attribute);
32
	}
33
34
	/**
35
	* {@inheritdoc}
36
	*/
37
	protected function normalizeElement(DOMElement $element)
38
	{
39
		$element->parentNode->removeChild($element);
40
	}
41
}