Completed
Push — master ( 1bd818...6fba0f )
by Richard
02:31
created

BeforeAfter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 16
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 6 4
1
<?php
2
namespace Transphporm\Property\ContentPseudo;
3
class BeforeAfter implements \Transphporm\Property\ContentPseudo {
4
    private $insertLocation;
5
    private $content;
6
7
    public function __construct($insertLocation, \Transphporm\Property\Content $content) {
8
        $this->insertLocation = $insertLocation;
9
		$this->content = $content;
10
	}
11
12
    public function run($value, $pseudoArgs, $element) {
13
        foreach ($this->content->getNode($value, $element->ownerDocument) as $node) {
14
			if ($this->insertLocation === "before") $element->insertBefore($node, $element->firstChild);
15
            else if ($this->insertLocation === "after") $element->appendChild($node);
16
		}
17
    }
18
}
19