Completed
Push — master ( 23863d...4a9b8e )
by Tom
02:43
created
src/Parser/Tokens.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 			if ($token['type'] === $tokenType) $i++;
79 79
 			else $splitTokens[$i][] = $token;
80 80
 		}
81
-        return array_map(function ($tokens) {
81
+        return array_map(function($tokens) {
82 82
             return new Tokens($tokens);
83 83
         }, $splitTokens);
84 84
 		//return $splitTokens;
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@  discard block
 block discarded – undo
6 6
  * @version         1.0                                                             */
7 7
 namespace Transphporm\Parser;
8 8
 class Tokens implements \Iterator, \Countable {
9
-    private $tokens;
10
-    private $iterator = 0;
9
+	private $tokens;
10
+	private $iterator = 0;
11 11
 
12
-    public function __construct(array $tokens) {
13
-        $this->tokens = $tokens;
14
-    }
12
+	public function __construct(array $tokens) {
13
+		$this->tokens = $tokens;
14
+	}
15 15
 
16
-    public function count() {
17
-        return count($this->tokens);
18
-    }
16
+	public function count() {
17
+		return count($this->tokens);
18
+	}
19 19
 
20
-    // Iterator Functions
21
-    public function current() {
22
-        return $this->tokens[$this->iterator];
23
-    }
20
+	// Iterator Functions
21
+	public function current() {
22
+		return $this->tokens[$this->iterator];
23
+	}
24 24
 
25
-    public function key() {
26
-        return $this->iterator;
27
-    }
25
+	public function key() {
26
+		return $this->iterator;
27
+	}
28 28
 
29
-    public function next() {
30
-        ++$this->iterator;
29
+	public function next() {
30
+		++$this->iterator;
31 31
 	}
32 32
 
33 33
 	public function valid() {
@@ -38,67 +38,67 @@  discard block
 block discarded – undo
38 38
 		$this->iterator = 0;
39 39
 	}
40 40
 
41
-    private function getKeysOfTokenType($tokenType) {
42
-        return array_keys(array_column($this->tokens, 'type'), $tokenType);
43
-    }
44
-
45
-    private function getKeyToSlice($tokenType) {
46
-        $keys = $this->getKeysOfTokenType($tokenType);
47
-        if (empty($keys)) return false;
48
-        $key = $keys[0];
49
-        for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) $key = $keys[$i];
50
-        return $key;
51
-    }
52
-
53
-    public function from($tokenType, $inclusive = false) {
54
-        $key = $this->getKeyToSlice($tokenType);
55
-        if ($key === false) return new Tokens([]);
56
-        if (!$inclusive) $key++;
57
-        return new Tokens(array_slice($this->tokens, $key));
58
-    }
59
-
60
-    public function to($tokenType, $inclusive = false) {
61
-        $key = $this->getKeyToSlice($tokenType);
62
-        if ($key === false) return new Tokens([]);
63
-        if ($inclusive) $key++;
64
-        return new Tokens(array_slice($this->tokens, $this->iterator, $key));
65
-    }
66
-
67
-    public function skip($count) {
68
-        $this->iterator += $count;
69
-    }
70
-
71
-    public function splitOnToken($tokenType) {
72
-        $splitTokens = [];
41
+	private function getKeysOfTokenType($tokenType) {
42
+		return array_keys(array_column($this->tokens, 'type'), $tokenType);
43
+	}
44
+
45
+	private function getKeyToSlice($tokenType) {
46
+		$keys = $this->getKeysOfTokenType($tokenType);
47
+		if (empty($keys)) return false;
48
+		$key = $keys[0];
49
+		for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) $key = $keys[$i];
50
+		return $key;
51
+	}
52
+
53
+	public function from($tokenType, $inclusive = false) {
54
+		$key = $this->getKeyToSlice($tokenType);
55
+		if ($key === false) return new Tokens([]);
56
+		if (!$inclusive) $key++;
57
+		return new Tokens(array_slice($this->tokens, $key));
58
+	}
59
+
60
+	public function to($tokenType, $inclusive = false) {
61
+		$key = $this->getKeyToSlice($tokenType);
62
+		if ($key === false) return new Tokens([]);
63
+		if ($inclusive) $key++;
64
+		return new Tokens(array_slice($this->tokens, $this->iterator, $key));
65
+	}
66
+
67
+	public function skip($count) {
68
+		$this->iterator += $count;
69
+	}
70
+
71
+	public function splitOnToken($tokenType) {
72
+		$splitTokens = [];
73 73
 		$i = 0;
74 74
 		foreach ($this->tokens as $token) {
75 75
 			if ($token['type'] === $tokenType) $i++;
76 76
 			else $splitTokens[$i][] = $token;
77 77
 		}
78
-        return array_map(function ($tokens) {
79
-            return new Tokens($tokens);
80
-        }, $splitTokens);
78
+		return array_map(function ($tokens) {
79
+			return new Tokens($tokens);
80
+		}, $splitTokens);
81 81
 		//return $splitTokens;
82
-    }
83
-
84
-    public function trim() {
85
-        $tokens = $this->tokens;
86
-        // Remove end whitespace
87
-        while (end($tokens)['type'] === Tokenizer::WHITESPACE) {
88
-            array_pop($tokens);
89
-        }
90
-        // Remove begining whitespace
91
-        while (isset($tokens[0]) && $tokens[0]['type'] === Tokenizer::WHITESPACE) {
92
-            array_shift($tokens);
93
-        }
94
-        return new Tokens($tokens);
95
-    }
96
-
97
-    public function read($offset = 0) {
98
-        return isset($this->tokens[$offset]) ? $this->tokens[$offset]['value'] : false;
99
-    }
100
-
101
-    public function type($offset = 0) {
102
-        return isset($this->tokens[$offset]) ? $this->tokens[$offset]['type'] : false;
103
-    }
82
+	}
83
+
84
+	public function trim() {
85
+		$tokens = $this->tokens;
86
+		// Remove end whitespace
87
+		while (end($tokens)['type'] === Tokenizer::WHITESPACE) {
88
+			array_pop($tokens);
89
+		}
90
+		// Remove begining whitespace
91
+		while (isset($tokens[0]) && $tokens[0]['type'] === Tokenizer::WHITESPACE) {
92
+			array_shift($tokens);
93
+		}
94
+		return new Tokens($tokens);
95
+	}
96
+
97
+	public function read($offset = 0) {
98
+		return isset($this->tokens[$offset]) ? $this->tokens[$offset]['value'] : false;
99
+	}
100
+
101
+	public function type($offset = 0) {
102
+		return isset($this->tokens[$offset]) ? $this->tokens[$offset]['type'] : false;
103
+	}
104 104
 }
Please login to merge, or discard this patch.
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,23 +44,35 @@  discard block
 block discarded – undo
44 44
 
45 45
     private function getKeyToSlice($tokenType) {
46 46
         $keys = $this->getKeysOfTokenType($tokenType);
47
-        if (empty($keys)) return false;
47
+        if (empty($keys)) {
48
+        	return false;
49
+        }
48 50
         $key = $keys[0];
49
-        for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) $key = $keys[$i];
51
+        for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) {
52
+        	$key = $keys[$i];
53
+        }
50 54
         return $key;
51 55
     }
52 56
 
53 57
     public function from($tokenType, $inclusive = false) {
54 58
         $key = $this->getKeyToSlice($tokenType);
55
-        if ($key === false) return new Tokens([]);
56
-        if (!$inclusive) $key++;
59
+        if ($key === false) {
60
+        	return new Tokens([]);
61
+        }
62
+        if (!$inclusive) {
63
+        	$key++;
64
+        }
57 65
         return new Tokens(array_slice($this->tokens, $key));
58 66
     }
59 67
 
60 68
     public function to($tokenType, $inclusive = false) {
61 69
         $key = $this->getKeyToSlice($tokenType);
62
-        if ($key === false) return new Tokens([]);
63
-        if ($inclusive) $key++;
70
+        if ($key === false) {
71
+        	return new Tokens([]);
72
+        }
73
+        if ($inclusive) {
74
+        	$key++;
75
+        }
64 76
         return new Tokens(array_slice($this->tokens, $this->iterator, $key));
65 77
     }
66 78
 
@@ -72,8 +84,11 @@  discard block
 block discarded – undo
72 84
         $splitTokens = [];
73 85
 		$i = 0;
74 86
 		foreach ($this->tokens as $token) {
75
-			if ($token['type'] === $tokenType) $i++;
76
-			else $splitTokens[$i][] = $token;
87
+			if ($token['type'] === $tokenType) {
88
+				$i++;
89
+			} else {
90
+				$splitTokens[$i][] = $token;
91
+			}
77 92
 		}
78 93
         return array_map(function ($tokens) {
79 94
             return new Tokens($tokens);
Please login to merge, or discard this patch.
src/Parser/Sheet.php 4 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -102,14 +102,14 @@
 block discarded – undo
102 102
 	}
103 103
 
104 104
 	private function getProperties($tokens) {
105
-        $rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON);
105
+		$rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON);
106 106
 
107
-        $return = [];
108
-        foreach ($rules as $rule) {
109
-            $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read();
110
-            $return[$name] = $rule->from(Tokenizer::COLON)->trim();
111
-        }
107
+		$return = [];
108
+		foreach ($rules as $rule) {
109
+			$name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read();
110
+			$return[$name] = $rule->from(Tokenizer::COLON)->trim();
111
+		}
112 112
 
113
-        return $return;
114
-    }
113
+		return $return;
114
+	}
115 115
 }
Please login to merge, or discard this patch.
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -43,6 +43,9 @@  discard block
 block discarded – undo
43 43
 		return $this->cache->write($this->file, $rules, $this->import);
44 44
 	}
45 45
 
46
+	/**
47
+	 * @param integer $indexStart
48
+	 */
46 49
 	private function parseTokens($indexStart) {
47 50
 		$this->rules = [];
48 51
 		$line = 1;
@@ -60,6 +63,9 @@  discard block
 block discarded – undo
60 63
 		return $this->rules;
61 64
 	}
62 65
 
66
+	/**
67
+	 * @param integer $line
68
+	 */
63 69
 	private function addRules($token, $indexStart, $line) {
64 70
 		$selector = $this->tss->from($token['type'], true)->to(Tokenizer::OPEN_BRACE);
65 71
 		$this->tss->skip(count($selector));
@@ -73,6 +79,9 @@  discard block
 block discarded – undo
73 79
 		if (empty($rules) && count($this->tss) > 0) throw new \Exception('No TSS rules parsed');
74 80
 	}
75 81
 
82
+	/**
83
+	 * @param integer $index
84
+	 */
76 85
 	private function CssToRules($selector, $index, $properties, $line) {
77 86
 		$parts = $selector->trim()->splitOnToken(Tokenizer::ARG);
78 87
 		$rules = [];
@@ -96,6 +105,9 @@  discard block
 block discarded – undo
96 105
 		return $rules;
97 106
 	}
98 107
 
108
+	/**
109
+	 * @param integer $indexStart
110
+	 */
99 111
 	private function processingInstructions($token, $indexStart) {
100 112
 		if ($token['type'] !== Tokenizer::AT_SIGN) return false;
101 113
 		$tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false);
@@ -123,6 +135,10 @@  discard block
 block discarded – undo
123 135
 		return ($a->depth < $b->depth) ? -1 : 1;
124 136
 	}
125 137
 
138
+	/**
139
+	 * @param string $open
140
+	 * @param string $close
141
+	 */
126 142
 	private function stripComments($str, $open, $close) {
127 143
 		$pos = 0;
128 144
 		while (($pos = strpos($str, $open, $pos)) !== false) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 		if (is_file($tss)) {
25 25
 			$this->file = $tss;
26 26
 			$this->rules = $this->cache->load($tss);
27
-			$baseDir = dirname(realpath($tss)) . DIRECTORY_SEPARATOR;
27
+			$baseDir = dirname(realpath($tss)).DIRECTORY_SEPARATOR;
28 28
 			if (empty($this->rules)) $tss = file_get_contents($tss);
29 29
 			else return;
30 30
 		}
Please login to merge, or discard this patch.
Braces   +31 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,8 +25,11 @@  discard block
 block discarded – undo
25 25
 			$this->file = $tss;
26 26
 			$this->rules = $this->cache->load($tss);
27 27
 			$baseDir = dirname(realpath($tss)) . DIRECTORY_SEPARATOR;
28
-			if (empty($this->rules)) $tss = file_get_contents($tss);
29
-			else return;
28
+			if (empty($this->rules)) {
29
+				$tss = file_get_contents($tss);
30
+			} else {
31
+				return;
32
+			}
30 33
 		}
31 34
 		$this->tss = $this->stripComments($tss, '//', "\n");
32 35
 		$this->tss = $this->stripComments($this->tss, '/*', '*/');
@@ -38,7 +41,9 @@  discard block
 block discarded – undo
38 41
 	}
39 42
 
40 43
 	public function parse($indexStart = 0) {
41
-		if (!empty($this->rules)) return $this->rules['rules'];
44
+		if (!empty($this->rules)) {
45
+			return $this->rules['rules'];
46
+		}
42 47
 		$rules = $this->parseTokens($indexStart);
43 48
 		usort($rules, [$this, 'sortRules']);
44 49
 		$this->checkError($rules);
@@ -52,12 +57,12 @@  discard block
 block discarded – undo
52 57
 			if ($processing = $this->processingInstructions($token, count($this->rules)+$indexStart)) {
53 58
 				$this->rules = array_merge($this->rules, $processing);
54 59
 				continue;
55
-			}
56
-			else if ($token['type'] === Tokenizer::NEW_LINE) {
60
+			} else if ($token['type'] === Tokenizer::NEW_LINE) {
57 61
 				$line++;
58 62
 				continue;
63
+			} else {
64
+				$this->addRules($token, $indexStart, $line);
59 65
 			}
60
-			else $this->addRules($token, $indexStart, $line);
61 66
 		}
62 67
 		return $this->rules;
63 68
 	}
@@ -65,14 +70,18 @@  discard block
 block discarded – undo
65 70
 	private function addRules($token, $indexStart, $line) {
66 71
 		$selector = $this->tss->from($token['type'], true)->to(Tokenizer::OPEN_BRACE);
67 72
 		$this->tss->skip(count($selector));
68
-		if (count($selector) === 0) return;
73
+		if (count($selector) === 0) {
74
+			return;
75
+		}
69 76
 
70 77
 		$newRules = $this->cssToRules($selector, count($this->rules)+$indexStart, $this->getProperties($this->tss->current()['value']), $line);
71 78
 		$this->rules = $this->writeRule($this->rules, $newRules);
72 79
 	}
73 80
 
74 81
 	private function checkError($rules) {
75
-		if (empty($rules) && count($this->tss) > 0) throw new \Exception('No TSS rules parsed');
82
+		if (empty($rules) && count($this->tss) > 0) {
83
+			throw new \Exception('No TSS rules parsed');
84
+		}
76 85
 	}
77 86
 
78 87
 	private function CssToRules($selector, $index, $properties, $line) {
@@ -99,7 +108,9 @@  discard block
 block discarded – undo
99 108
 	}
100 109
 
101 110
 	private function processingInstructions($token, $indexStart) {
102
-		if ($token['type'] !== Tokenizer::AT_SIGN) return false;
111
+		if ($token['type'] !== Tokenizer::AT_SIGN) {
112
+			return false;
113
+		}
103 114
 		$tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false);
104 115
 		$funcName = $tokens->from(Tokenizer::NAME, true)->read();
105 116
 		$args = $this->valueParser->parseTokens($tokens->from(Tokenizer::NAME));
@@ -111,8 +122,11 @@  discard block
 block discarded – undo
111 122
 	}
112 123
 
113 124
 	private function import($args, $indexStart) {
114
-		if ($this->file !== null) $fileName = $fileName = $this->filePath->getFilePath($args[0]);
115
-		else $fileName = $args[0];
125
+		if ($this->file !== null) {
126
+			$fileName = $fileName = $this->filePath->getFilePath($args[0]);
127
+		} else {
128
+			$fileName = $args[0];
129
+		}
116 130
 		$this->import[] = $fileName;
117 131
 		$baseDirTemp = $this->baseDir;
118 132
 		$sheet = new Sheet($fileName, $this->baseDir, $this->xPath, $this->valueParser, $this->cache, $this->filePath);
@@ -122,7 +136,9 @@  discard block
 block discarded – undo
122 136
 
123 137
 	private function sortRules($a, $b) {
124 138
 		//If they have the same depth, compare on index
125
-		if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1;
139
+		if ($a->depth === $b->depth) {
140
+			return $a->index < $b->index ? -1 : 1;
141
+		}
126 142
 
127 143
 		return ($a->depth < $b->depth) ? -1 : 1;
128 144
 	}
@@ -131,7 +147,9 @@  discard block
 block discarded – undo
131 147
 		$pos = 0;
132 148
 		while (($pos = strpos($str, $open, $pos)) !== false) {
133 149
 			$end = strpos($str, $close, $pos);
134
-			if ($end === false) break;
150
+			if ($end === false) {
151
+				break;
152
+			}
135 153
 			$str = substr_replace($str, '', $pos, $end-$pos+strlen($close));
136 154
 		}
137 155
 
Please login to merge, or discard this patch.
src/Config.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,12 +67,16 @@
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	public function loadProperties(Hook\PropertyHook $hook) {
70
-		foreach ($this->properties as $name => $property) $hook->registerProperty($name, $property);
70
+		foreach ($this->properties as $name => $property) {
71
+			$hook->registerProperty($name, $property);
72
+		}
71 73
 	}
72 74
 
73 75
 	public function createPseudoMatcher($pseudo) {
74 76
 		$pseudoMatcher = new Hook\PseudoMatcher($pseudo, $this->valueParser);
75
-		foreach ($this->pseudo as $pseudoFunction) $pseudoMatcher->registerFunction(clone $pseudoFunction);
77
+		foreach ($this->pseudo as $pseudoFunction) {
78
+			$pseudoMatcher->registerFunction(clone $pseudoFunction);
79
+		}
76 80
 		return $pseudoMatcher;
77 81
 	}
78 82
 
Please login to merge, or discard this patch.
src/Parser/TokenFilterIterator.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
  * @version         1.0                                                             */
7 7
 namespace Transphporm\Parser;
8 8
 class TokenFilterIterator implements \Iterator {
9
-    private $ignore;
10
-    private $tokens;
9
+	private $ignore;
10
+	private $tokens;
11 11
 
12
-    public function __construct(Tokens $tokens, array $ignore) {
13
-        $this->ignore = $ignore;
14
-        $this->tokens = $tokens;
15
-    }
12
+	public function __construct(Tokens $tokens, array $ignore) {
13
+		$this->ignore = $ignore;
14
+		$this->tokens = $tokens;
15
+	}
16 16
 
17
-    public function current() {
18
-        return $this->tokens->current();
19
-    }
17
+	public function current() {
18
+		return $this->tokens->current();
19
+	}
20 20
 
21
-    public function key() {
22
-        return $this->tokens->key();
23
-    }
21
+	public function key() {
22
+		return $this->tokens->key();
23
+	}
24 24
 
25
-    public function valid() {
26
-        return $this->tokens->valid();
27
-    }
25
+	public function valid() {
26
+		return $this->tokens->valid();
27
+	}
28 28
 
29
-    public function next() {
30
-        do {
31
-            $this->tokens->next();
32
-        }
33
-        while ($this->shouldContinue());
34
-    }
29
+	public function next() {
30
+		do {
31
+			$this->tokens->next();
32
+		}
33
+		while ($this->shouldContinue());
34
+	}
35 35
 
36
-    public function rewind() {
37
-        $this->tokens->rewind();
38
-        while ($this->shouldContinue()) $this->tokens->next();
39
-    }
36
+	public function rewind() {
37
+		$this->tokens->rewind();
38
+		while ($this->shouldContinue()) $this->tokens->next();
39
+	}
40 40
 
41
-    private function shouldContinue() {
42
-        return $this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore);
43
-    }
41
+	private function shouldContinue() {
42
+		return $this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore);
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@
 block discarded – undo
35 35
 
36 36
     public function rewind() {
37 37
         $this->tokens->rewind();
38
-        while ($this->shouldContinue()) $this->tokens->next();
38
+        while ($this->shouldContinue()) {
39
+        	$this->tokens->next();
40
+        }
39 41
     }
40 42
 
41 43
     private function shouldContinue() {
Please login to merge, or discard this patch.
src/Builder.php 3 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -62,6 +62,10 @@  discard block
 block discarded – undo
62 62
 		return (object) $result;
63 63
 	}
64 64
 
65
+	/**
66
+	 * @param Template $template
67
+	 * @param Config $config
68
+	 */
65 69
 	private function processRules($template, $config) {
66 70
 		$rules = $this->getRules($template, $config);
67 71
 
@@ -71,6 +75,10 @@  discard block
 block discarded – undo
71 75
 	}
72 76
 
73 77
 	//Add a postprocessing hook. This cleans up anything transphporm has added to the markup which needs to be removed
78
+
79
+	/**
80
+	 * @param Template $template
81
+	 */
74 82
 	private function doPostProcessing($template) {
75 83
 		$template->addHook('//*[@transphporm]', new Hook\PostProcess());
76 84
 		return $template;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 
53 53
 		$cachedOutput = $this->loadTemplate();
54 54
 		//To be a valid XML document it must have a root element, automatically wrap it in <template> to ensure it does
55
-		$template = new Template($this->isValidDoc($cachedOutput['body']) ? str_ireplace('<!doctype', '<!DOCTYPE', $cachedOutput['body']) : '<template>' . $cachedOutput['body'] . '</template>' );
55
+		$template = new Template($this->isValidDoc($cachedOutput['body']) ? str_ireplace('<!doctype', '<!DOCTYPE', $cachedOutput['body']) : '<template>'.$cachedOutput['body'].'</template>');
56 56
 		$valueParser = new Parser\Value($data);
57 57
 		$config = new Config($data, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($data, $template->getPrefix()), new FilePath($this->baseDir, $this->rootDir), $headers);
58 58
 
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
 		$this->cache = new Cache(new \ArrayObject());
28 28
 
29 29
 		$modules = is_array($modules) ? $modules : $this->defaultModules;
30
-		foreach ($modules as $module) $this->loadModule(new $module);
30
+		foreach ($modules as $module) {
31
+			$this->loadModule(new $module);
32
+		}
31 33
 	}
32 34
 
33 35
 	//Allow setting the time used by Transphporm for caching. This is for testing purposes
@@ -56,7 +58,9 @@  discard block
 block discarded – undo
56 58
 		$valueParser = new Parser\Value($data);
57 59
 		$config = new Config($data, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($data, $template->getPrefix()), new FilePath($this->baseDir, $this->rootDir), $headers);
58 60
 
59
-		foreach ($this->modules as $module) $module->load($config);
61
+		foreach ($this->modules as $module) {
62
+			$module->load($config);
63
+		}
60 64
 
61 65
 		$this->processRules($template, $config);
62 66
 
@@ -71,7 +75,9 @@  discard block
 block discarded – undo
71 75
 		$rules = $this->getRules($template, $config);
72 76
 
73 77
 		foreach ($rules as $rule) {
74
-			if ($rule->shouldRun($this->time)) $this->executeTssRule($rule, $template, $config);
78
+			if ($rule->shouldRun($this->time)) {
79
+				$this->executeTssRule($rule, $template, $config);
80
+			}
75 81
 		}
76 82
 	}
77 83
 
@@ -96,8 +102,9 @@  discard block
 block discarded – undo
96 102
 		if (trim($this->template)[0] !== '<') {
97 103
 			$xml = $this->cache->load($this->template, filemtime($this->template));
98 104
 			return $xml ? $xml : ['body' => file_get_contents($this->template), 'headers' => []];
105
+		} else {
106
+			return ['body' => $this->template, 'headers' => []];
99 107
 		}
100
-		else return ['body' => $this->template, 'headers' => []];
101 108
 	}
102 109
 
103 110
 	//Load the TSS rules either from a file or as a string
Please login to merge, or discard this patch.
src/RunException.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm;
3 3
 class RunException extends \Exception {
4
-    public function __construct($operationType, $operationName, \Exception $previous) {
5
-        $message = 'TSS Error: Problem carrying out ' . $operationType . ' \'' . $operationName . '\'';
4
+	public function __construct($operationType, $operationName, \Exception $previous) {
5
+		$message = 'TSS Error: Problem carrying out ' . $operationType . ' \'' . $operationName . '\'';
6 6
 
7
-        parent::__construct($message, 0, $previous);
8
-    }
7
+		parent::__construct($message, 0, $previous);
8
+	}
9 9
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 namespace Transphporm;
3 3
 class RunException extends \Exception {
4 4
     public function __construct($operationType, $operationName, \Exception $previous) {
5
-        $message = 'TSS Error: Problem carrying out ' . $operationType . ' \'' . $operationName . '\'';
5
+        $message = 'TSS Error: Problem carrying out '.$operationType.' \''.$operationName.'\'';
6 6
 
7 7
         parent::__construct($message, 0, $previous);
8 8
     }
Please login to merge, or discard this patch.
src/Exception.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm;
3 3
 class Exception extends \Exception {
4
-    const PROPERTY = 'property';
5
-    const TSS_FUNCTION = 'function';
6
-    const PSEUDO = 'pseudo';
7
-    const FORMATTER = 'formatter';
4
+	const PROPERTY = 'property';
5
+	const TSS_FUNCTION = 'function';
6
+	const PSEUDO = 'pseudo';
7
+	const FORMATTER = 'formatter';
8 8
 
9
-    public function __construct(RunException $runException, $file, $line) {
10
-        $message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);
9
+	public function __construct(RunException $runException, $file, $line) {
10
+		$message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);
11 11
 
12
-        parent::__construct($message, 0, $runException->getPrevious());
13
-    }
12
+		parent::__construct($message, 0, $runException->getPrevious());
13
+	}
14 14
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
     const FORMATTER = 'formatter';
8 8
 
9 9
     public function __construct(RunException $runException, $file, $line) {
10
-        $message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);
10
+        $message = $runException->getMessage().' on Line '.$line.' of '.($file === null ? 'tss' : $file);
11 11
 
12 12
         parent::__construct($message, 0, $runException->getPrevious());
13 13
     }
Please login to merge, or discard this patch.
src/Hook/Formatter.php 1 patch
Braces   +7 added lines, -4 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 format($value, $rules) {
17
-		if (!isset($rules['format'])) return $value;
17
+		if (!isset($rules['format'])) {
18
+			return $value;
19
+		}
18 20
 		$tokens = $rules['format'];
19 21
 
20 22
 		$functionName = $tokens->from(\Transphporm\Parser\Tokenizer::NAME, true)->read();
@@ -27,8 +29,7 @@  discard block
 block discarded – undo
27 29
 
28 30
 		try {
29 31
 			return $this->processFormat($options, $functionName, $value);
30
-		}
31
-		catch (\Exception $e) {
32
+		} catch (\Exception $e) {
32 33
 			throw new \Transphporm\RunException(\Transphporm\Exception::FORMATTER, $functionName, $e);
33 34
 		}
34 35
 	}
@@ -43,7 +44,9 @@  discard block
 block discarded – undo
43 44
 				}
44 45
 			}
45 46
 		}
46
-		if (!$functionExists) throw new \Exception("Formatter '$functionName' does not exist");
47
+		if (!$functionExists) {
48
+			throw new \Exception("Formatter '$functionName' does not exist");
49
+		}
47 50
 		return $value;
48 51
 	}
49 52
 }
Please login to merge, or discard this patch.
src/Hook/PropertyHook.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
 	public function run(\DomElement $element) {
32 32
 		$this->functionSet->setElement($element);
33
-		if ($this->file !== null) $this->baseDir = dirname(realpath($this->file)) . DIRECTORY_SEPARATOR;
33
+		if ($this->file !== null) $this->baseDir = dirname(realpath($this->file)).DIRECTORY_SEPARATOR;
34 34
 		$this->configLine = $this->line;
35 35
 		try {
36 36
 			//Don't run if there's a pseudo element like nth-child() and this element doesn't match it
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,11 +30,15 @@  discard block
 block discarded – undo
30 30
 
31 31
 	public function run(\DomElement $element) {
32 32
 		$this->functionSet->setElement($element);
33
-		if ($this->file !== null) $this->baseDir = dirname(realpath($this->file)) . DIRECTORY_SEPARATOR;
33
+		if ($this->file !== null) {
34
+			$this->baseDir = dirname(realpath($this->file)) . DIRECTORY_SEPARATOR;
35
+		}
34 36
 		$this->configLine = $this->line;
35 37
 		try {
36 38
 			//Don't run if there's a pseudo element like nth-child() and this element doesn't match it
37
-			if (!$this->pseudoMatcher->matches($element)) return;
39
+			if (!$this->pseudoMatcher->matches($element)) {
40
+				return;
41
+			}
38 42
 
39 43
 			// TODO: Have all rule values parsed before running them so that things like `content-append` are not expecting tokens
40 44
 			// problem with this is that anything in data changed by run properties is not shown
@@ -42,10 +46,11 @@  discard block
 block discarded – undo
42 46
 
43 47
 			foreach ($this->rules as $name => $value) {
44 48
 				$result = $this->callProperty($name, $element, $this->getArgs($value));
45
-				if ($result === false) break;
49
+				if ($result === false) {
50
+					break;
51
+				}
46 52
 			}
47
-		}
48
-		catch (\Transphporm\RunException $e) {
53
+		} catch (\Transphporm\RunException $e) {
49 54
 			throw new \Transphporm\Exception($e, $this->file, $this->line);
50 55
 		}
51 56
 	}
@@ -62,9 +67,10 @@  discard block
 block discarded – undo
62 67
 		if (isset($this->properties[$name])) {
63 68
 			try {
64 69
 				return $this->properties[$name]->run($value, $element, $this->rules, $this->pseudoMatcher, $this->properties);
65
-			}
66
-			catch (\Exception $e) {
67
-				if ($e instanceof \Transphporm\RunException) throw $e;
70
+			} catch (\Exception $e) {
71
+				if ($e instanceof \Transphporm\RunException) {
72
+					throw $e;
73
+				}
68 74
 				throw new \Transphporm\RunException(\Transphporm\Exception::PROPERTY, $name, $e);
69 75
 			}
70 76
 		}
Please login to merge, or discard this patch.