Completed
Push — master ( 878197...378399 )
by Tom
07:30
created

PostProcess::runOnImmutableElements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/* @description     Transformation Style Sheets - Revolutionising PHP templating    *
3
 * @author          Tom Butler [email protected]                                             *
4
 * @copyright       2017 Tom Butler <[email protected]> | https://r.je/                      *
5
 * @license         http://www.opensource.org/licenses/bsd-license.php  BSD License *
6
 * @version         1.2                                                             */
7
namespace Transphporm\Hook;
8
/** Hooks into the template system, gets assigned as `ul li` or similar and `run()` is called with any elements that match */
9
class PostProcess implements \Transphporm\Hook {
10
	public function run(\DomElement $element) {
11
		$transphporm = $element->getAttribute('transphporm');
12
		if ($transphporm === 'remove') $element->parentNode->removeChild($element);
13
		else if ($transphporm === 'text') $element->parentNode->replaceChild($element->firstChild, $element);
14
		else $element->removeAttribute('transphporm');
15
	}
16
17
	public function runOnImmutableElements(): bool {
18
		return true;
19
	}
20
}