Completed
Push — master ( 9caa90...8321d8 )
by Tom
02:40
created
src/PropertyBuilder.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@
 block discarded – undo
20 20
 		$formatter->register(new Formatter\Date($locale));
21 21
 		$formatter->register(new Formatter\StringFormatter());
22 22
 		
23
-		foreach ($formatters as $format) $formatter->register($format);
23
+		foreach ($formatters as $format) {
24
+			$formatter->register($format);
25
+		}
24 26
 
25 27
 		$this->builder->registerProperty('content', new Property\Content($data, $headers, $formatter));
26 28
 		$this->builder->registerProperty('repeat', new Property\Repeat($data));
Please login to merge, or discard this patch.
src/Builder.php 1 patch
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 	private function processRules($template, $data) {
53 53
 		$valueParser = new Parser\Value($data);
54 54
 		foreach ($this->getRules($template, $valueParser) as $rule) {
55
-			if ($rule->shouldRun($this->time)) $this->executeTssRule($rule, $template, $data, $valueParser);			
55
+			if ($rule->shouldRun($this->time)) {
56
+				$this->executeTssRule($rule, $template, $data, $valueParser);
57
+			}
56 58
 		}
57 59
 	}
58 60
 
@@ -66,7 +68,9 @@  discard block
 block discarded – undo
66 68
 	private function executeTssRule($rule, $template, $data, $valueParser) {
67 69
 		$rule->touch();
68 70
 		$hook = new Hook\PropertyHook($rule->properties, new Hook\PseudoMatcher($rule->pseudo, $data), $valueParser);
69
-		foreach ($this->registeredProperties as $name => $property) $hook->registerProperty($name, $property);
71
+		foreach ($this->registeredProperties as $name => $property) {
72
+			$hook->registerProperty($name, $property);
73
+		}
70 74
 		$template->addHook($rule->query, $hook);
71 75
 	}
72 76
 
@@ -75,8 +79,9 @@  discard block
 block discarded – undo
75 79
 		if (trim($this->template)[0] !== '<') {			
76 80
 			$xml = $this->cache->load($this->template, filemtime($this->template));
77 81
 			return $xml ? $xml : ['body' => file_get_contents($this->template), 'headers' => []];
82
+		} else {
83
+			return ['body' => $this->template, 'headers' => []];
78 84
 		}
79
-		else return ['body' => $this->template, 'headers' => []];	
80 85
 	}
81 86
 
82 87
 	//Load the TSS rules either from a file or as a string
@@ -90,10 +95,14 @@  discard block
 block discarded – undo
90 95
 			$key = $this->tss . $template->getPrefix() . $this->baseDir;
91 96
 			//Try to load the cached rules, if not set in the cache (or expired) parse the supplied sheet
92 97
 			$rules = $this->cache->load($key, filemtime($this->tss));
93
-			if (!$rules) return $this->cache->write($key, (new Parser\Sheet(file_get_contents($this->tss), $this->baseDir, $valueParser, $template->getPrefix()))->parse());
94
-			else return $rules;
98
+			if (!$rules) {
99
+				return $this->cache->write($key, (new Parser\Sheet(file_get_contents($this->tss), $this->baseDir, $valueParser, $template->getPrefix()))->parse());
100
+			} else {
101
+				return $rules;
102
+			}
103
+		} else {
104
+			return (new Parser\Sheet($this->tss, $this->baseDir, $valueParser, $template->getPrefix()))->parse();
95 105
 		}
96
-		else return (new Parser\Sheet($this->tss, $this->baseDir, $valueParser, $template->getPrefix()))->parse();
97 106
 	}
98 107
 
99 108
 	public function setCache(\ArrayAccess $cache) {
@@ -101,9 +110,13 @@  discard block
 block discarded – undo
101 110
 	}
102 111
 
103 112
 	private function getLocale() {
104
-		if (is_array($this->locale)) return $this->locale;
105
-		else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);
106
-		else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);
113
+		if (is_array($this->locale)) {
114
+			return $this->locale;
115
+		} else if (strlen($this->locale) > 0) {
116
+			return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);
117
+		} else {
118
+			return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);
119
+		}
107 120
 	}
108 121
 
109 122
 	public function registerProperty($name, Property $property) {
Please login to merge, or discard this patch.
src/Parser/Sheet.php 1 patch
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 			$rules = $this->writeRule($rules, $selector, $rule);
34 34
 		}
35 35
 		//there may be processing instructions at the end
36
-		if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss))) $rules = array_merge($processing['rules'], $rules);
36
+		if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss))) {
37
+			$rules = array_merge($processing['rules'], $rules);
38
+		}
37 39
 		usort($rules, [$this, 'sortRules']);
38 40
 		return $rules;
39 41
 	}
@@ -63,8 +65,7 @@  discard block
 block discarded – undo
63 65
 				$pos = strpos($tss, ';', $spacePos);
64 66
 				$args = substr($tss, $spacePos+1, $pos-$spacePos-1);
65 67
 				$rules = array_merge($rules, $this->$funcName($args));
66
-			}
67
-			else {
68
+			} else {
68 69
 				break;	
69 70
 			} 
70 71
 		}
@@ -79,7 +80,9 @@  discard block
 block discarded – undo
79 80
 
80 81
 	private function sortRules($a, $b) {
81 82
 		//If they have the same depth, compare on index
82
-		if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1;
83
+		if ($a->depth === $b->depth) {
84
+			return $a->index < $b->index ? -1 : 1;
85
+		}
83 86
 
84 87
 		return ($a->depth < $b->depth) ? -1 : 1;
85 88
 	}
@@ -100,7 +103,9 @@  discard block
 block discarded – undo
100 103
 		$return = [];
101 104
 
102 105
 		foreach ($rules as $rule) {
103
-			if (trim($rule) === '') continue;
106
+			if (trim($rule) === '') {
107
+				continue;
108
+			}
104 109
 			$parts = explode(':', $rule, 2);
105 110
 
106 111
 			$parts[1] = $stringExtractor->rebuild($parts[1]);
Please login to merge, or discard this patch.
src/Property/Content.php 1 patch
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,15 +18,20 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	public function run($value, \DomElement $element, \Transphporm\Hook\PropertyHook $rule) {
21
-		if ($element->getAttribute('transphporm') === 'remove') return;
21
+		if ($element->getAttribute('transphporm') === 'remove') {
22
+			return;
23
+		}
22 24
 				
23 25
 		$value = $this->formatter->format($value, $rule->getRules());
24 26
 		if (!$this->processPseudo($value, $element, $rule)) {
25 27
 			//Remove the current contents
26 28
 			$this->removeAllChildren($element);
27 29
 			//Now make a text node
28
-			if ($this->getContentMode($rule->getRules()) === 'replace') $this->replaceContent($element, $value);
29
-			else $this->appendContent($element, $value);
30
+			if ($this->getContentMode($rule->getRules()) === 'replace') {
31
+				$this->replaceContent($element, $value);
32
+			} else {
33
+				$this->appendContent($element, $value);
34
+			}
30 35
 		}
31 36
 	}
32 37
 
@@ -92,6 +97,8 @@  discard block
 block discarded – undo
92 97
 	}
93 98
 
94 99
 	private function removeAllChildren($element) {
95
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
100
+		while ($element->hasChildNodes()) {
101
+			$element->removeChild($element->firstChild);
102
+		}
96 103
 	}
97 104
 }
98 105
\ No newline at end of file
Please login to merge, or discard this patch.