Completed
Push — master ( 1bd818...6fba0f )
by Richard
02:31
created
src/Property/ContentPseudo.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,5 +2,5 @@
 block discarded – undo
2 2
 namespace Transphporm\Property;
3 3
 
4 4
 interface ContentPseudo {
5
-    public function run($value, $pseudoArgs, $element);
5
+	public function run($value, $pseudoArgs, $element);
6 6
 }
Please login to merge, or discard this patch.
src/Property/Content.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@
 block discarded – undo
39 39
 		return (isset($rules['content-mode'])) ? $rules['content-mode']->read() : 'append';
40 40
 	}
41 41
 
42
-    public function addContentPseudo($name, ContentPseudo $contentPseudo) {
43
-        $this->contentPseudo[$name] = $contentPseudo;
44
-    }
42
+	public function addContentPseudo($name, ContentPseudo $contentPseudo) {
43
+		$this->contentPseudo[$name] = $contentPseudo;
44
+	}
45 45
     
46 46
 	private function processPseudo($value, $element, $pseudoMatcher) {
47 47
 		foreach ($this->contentPseudo as $pseudoName => $pseudoFunction) {
Please login to merge, or discard this patch.
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
17
-		if (!$this->shouldRun($element)) return false;
17
+		if (!$this->shouldRun($element)) {
18
+			return false;
19
+		}
18 20
 
19 21
 		$values = $this->formatter->format($values, $rules);
20 22
 
@@ -22,14 +24,19 @@  discard block
 block discarded – undo
22 24
 			//Remove the current contents
23 25
 			$this->removeAllChildren($element);
24 26
 			//Now make a text node
25
-			if ($this->getContentMode($rules) === 'replace') $this->replaceContent($element, $values);
26
-			else $this->appendContent($element, $values);
27
+			if ($this->getContentMode($rules) === 'replace') {
28
+				$this->replaceContent($element, $values);
29
+			} else {
30
+				$this->appendContent($element, $values);
31
+			}
27 32
 		}
28 33
 	}
29 34
 
30 35
 	private function shouldRun($element) {
31 36
 		do {
32
-			if ($element->getAttribute('transphporm') == 'includedtemplate') return false;
37
+			if ($element->getAttribute('transphporm') == 'includedtemplate') {
38
+				return false;
39
+			}
33 40
 		}
34 41
 		while (($element = $element->parentNode) instanceof \DomElement);
35 42
 		return true;
@@ -56,9 +63,10 @@  discard block
 block discarded – undo
56 63
 	public function getNode($node, $document) {
57 64
 		foreach ($node as $n) {
58 65
 			if (is_array($n)) {
59
-				foreach ($this->getNode($n, $document) as $new) yield $new;
60
-			}
61
-			else {
66
+				foreach ($this->getNode($n, $document) as $new) {
67
+					yield $new;
68
+				}
69
+			} else {
62 70
 				yield $this->convertNode($n, $document);
63 71
 			}
64 72
 		}
@@ -69,9 +77,10 @@  discard block
 block discarded – undo
69 77
 			$new = $document->importNode($node, true);
70 78
 			//Removing this might cause problems with caching...
71 79
 			//$new->setAttribute('transphporm', 'added');
72
-		}
73
-		else {
74
-			if ($node instanceof \DomText) $node = $node->nodeValue;
80
+		} else {
81
+			if ($node instanceof \DomText) {
82
+				$node = $node->nodeValue;
83
+			}
75 84
 			$new = $document->createElement('text');
76 85
 
77 86
 			$new->appendChild($document->createTextNode($node));
@@ -95,6 +104,8 @@  discard block
 block discarded – undo
95 104
 	}
96 105
 
97 106
 	private function removeAllChildren($element) {
98
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
107
+		while ($element->hasChildNodes()) {
108
+			$element->removeChild($element->firstChild);
109
+		}
99 110
 	}
100 111
 }
Please login to merge, or discard this patch.
src/Property/ContentPseudo/Attr.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm\Property\ContentPseudo;
3 3
 class Attr implements \Transphporm\Property\ContentPseudo {
4
-    public function run($value, $pseudoArgs, $element) {
5
-        $element->setAttribute($pseudoArgs, implode('', $value));
6
-    }
4
+	public function run($value, $pseudoArgs, $element) {
5
+		$element->setAttribute($pseudoArgs, implode('', $value));
6
+	}
7 7
 }
Please login to merge, or discard this patch.
src/Property/ContentPseudo/BeforeAfter.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm\Property\ContentPseudo;
3 3
 class BeforeAfter implements \Transphporm\Property\ContentPseudo {
4
-    private $insertLocation;
5
-    private $content;
4
+	private $insertLocation;
5
+	private $content;
6 6
 
7
-    public function __construct($insertLocation, \Transphporm\Property\Content $content) {
8
-        $this->insertLocation = $insertLocation;
7
+	public function __construct($insertLocation, \Transphporm\Property\Content $content) {
8
+		$this->insertLocation = $insertLocation;
9 9
 		$this->content = $content;
10 10
 	}
11 11
 
12
-    public function run($value, $pseudoArgs, $element) {
13
-        foreach ($this->content->getNode($value, $element->ownerDocument) as $node) {
12
+	public function run($value, $pseudoArgs, $element) {
13
+		foreach ($this->content->getNode($value, $element->ownerDocument) as $node) {
14 14
 			if ($this->insertLocation === "before") $element->insertBefore($node, $element->firstChild);
15
-            else if ($this->insertLocation === "after") $element->appendChild($node);
15
+			else if ($this->insertLocation === "after") $element->appendChild($node);
16 16
 		}
17
-    }
17
+	}
18 18
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,11 @@
 block discarded – undo
11 11
 
12 12
     public function run($value, $pseudoArgs, $element) {
13 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);
14
+			if ($this->insertLocation === "before") {
15
+				$element->insertBefore($node, $element->firstChild);
16
+			} else if ($this->insertLocation === "after") {
17
+            	$element->appendChild($node);
18
+            }
16 19
 		}
17 20
     }
18 21
 }
Please login to merge, or discard this patch.
src/Property/ContentPseudo/Headers.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm\Property\ContentPseudo;
3 3
 class Headers implements \Transphporm\Property\ContentPseudo {
4
-    private $headers;
4
+	private $headers;
5 5
 
6
-    public function __construct(&$headers) {
6
+	public function __construct(&$headers) {
7 7
 		$this->headers = &$headers;
8 8
 	}
9 9
 
10
-    public function run($value, $pseudoArgs, $element) {
11
-        $this->headers[] = [$pseudoArgs, implode('', $value)];
12
-    }
10
+	public function run($value, $pseudoArgs, $element) {
11
+		$this->headers[] = [$pseudoArgs, implode('', $value)];
12
+	}
13 13
 }
Please login to merge, or discard this patch.
src/Module/Basics.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@
 block discarded – undo
13 13
 		$data = $config->getFunctionSet();
14 14
 		$headers = &$config->getHeaders();
15 15
 
16
-        $content = new \Transphporm\Property\Content($config->getFormatter());
16
+		$content = new \Transphporm\Property\Content($config->getFormatter());
17 17
 		$config->registerProperty('content', $content);
18 18
 		$config->registerProperty('repeat', new \Transphporm\Property\Repeat($data, $config->getElementData(), $config->getLine(), $config->getFilePath()));
19 19
 		$config->registerProperty('display', new \Transphporm\Property\Display);
20 20
 		$config->registerProperty('bind', new \Transphporm\Property\Bind($config->getElementData()));
21 21
 
22
-        $content->addContentPseudo("before", new \Transphporm\Property\ContentPseudo\BeforeAfter("before", $content));
23
-        $content->addContentPseudo("after", new \Transphporm\Property\ContentPseudo\BeforeAfter("after", $content));
24
-        $content->addContentPseudo("attr", new \Transphporm\Property\ContentPseudo\Attr());
25
-        $content->addContentPseudo("header", new \Transphporm\Property\ContentPseudo\Headers($headers));
22
+		$content->addContentPseudo("before", new \Transphporm\Property\ContentPseudo\BeforeAfter("before", $content));
23
+		$content->addContentPseudo("after", new \Transphporm\Property\ContentPseudo\BeforeAfter("after", $content));
24
+		$content->addContentPseudo("attr", new \Transphporm\Property\ContentPseudo\Attr());
25
+		$content->addContentPseudo("header", new \Transphporm\Property\ContentPseudo\Headers($headers));
26 26
 	}
27 27
 }
Please login to merge, or discard this patch.