Attr::run()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
rs 9.7666
cc 3
nc 3
nop 4
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\Property\ContentPseudo;
8
class Attr implements \Transphporm\Property\ContentPseudo {
9
	public function run($value, $pseudoArgs, $element, \Transphporm\Hook\PseudoMatcher $pseudoMatcher) {
10
		$implodedValue = implode('', $value);
11
12
		if ($pseudoMatcher->hasFunction('before')) {
13
			$attrValue = $implodedValue . $element->getAttribute($pseudoArgs);
14
		}
15
		else if ($pseudoMatcher->hasFunction('after')) {
16
			$attrValue = $element->getAttribute($pseudoArgs) . $implodedValue;
17
		}
18
		else {
19
			$attrValue = implode('', $value);
20
		}
21
22
		$element->setAttribute($pseudoArgs, $attrValue);
23
	}
24
}
25