Completed
Push — master ( 02c8a1...58faf5 )
by Tom
02:14
created

src/Property/ContentPseudo/BeforeAfter.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 BeforeAfter implements \Transphporm\Property\ContentPseudo {
9
	private $insertLocation;
10
	private $content;
11
12
	public function __construct($insertLocation, \Transphporm\Property\Content $content) {
13
		$this->insertLocation = $insertLocation;
14
		$this->content = $content;
15
	}
16
17
	public function run($value, $pseudoArgs, $element, \Transphporm\Hook\PseudoMatcher $pseudoMatcher) {
18
		$currentFirst = $element->firstChild;
19
20
		foreach ($this->content->getNode($value, $element->ownerDocument) as $node) {
21
			$this->{$this->insertLocation}($node, $element, $currentFirst);
22
		}
23
	}
24
25
	private function before($node, $element, $currentFirst) {		
26
		$element->insertBefore($node, $currentFirst);
27
	}
28
29
	private function after($node, $element, $currentFirst) {
0 ignored issues
show
The parameter $currentFirst is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
		$element->appendChild($node);
31
	}
32
}
33