Completed
Push — master ( aa44e7...3b6d57 )
by Tom
02:09
created
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
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 		if (is_file($tss)) {
23 23
 			$this->file = $tss;
24 24
 			$this->rules = $this->cache->load($tss);
25
-			$filePath->setBaseDir(dirname(realpath($tss)) . DIRECTORY_SEPARATOR);
25
+			$filePath->setBaseDir(dirname(realpath($tss)).DIRECTORY_SEPARATOR);
26 26
 			if (empty($this->rules)) $tss = file_get_contents($tss);
27 27
 			else return;
28 28
 		}
Please login to merge, or discard this patch.
Braces   +31 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,8 +23,11 @@  discard block
 block discarded – undo
23 23
 			$this->file = $tss;
24 24
 			$this->rules = $this->cache->load($tss);
25 25
 			$filePath->setBaseDir(dirname(realpath($tss)) . DIRECTORY_SEPARATOR);
26
-			if (empty($this->rules)) $tss = file_get_contents($tss);
27
-			else return;
26
+			if (empty($this->rules)) {
27
+				$tss = file_get_contents($tss);
28
+			} else {
29
+				return;
30
+			}
28 31
 		}
29 32
 		$this->tss = $this->stripComments($tss, '//', "\n");
30 33
 		$this->tss = $this->stripComments($this->tss, '/*', '*/');
@@ -36,7 +39,9 @@  discard block
 block discarded – undo
36 39
 	}
37 40
 
38 41
 	public function parse($indexStart = 0) {
39
-		if (!empty($this->rules)) return $this->rules['rules'];
42
+		if (!empty($this->rules)) {
43
+			return $this->rules['rules'];
44
+		}
40 45
 		$rules = $this->parseTokens($indexStart);
41 46
 		usort($rules, [$this, 'sortRules']);
42 47
 		$this->checkError($rules);
@@ -50,12 +55,12 @@  discard block
 block discarded – undo
50 55
 			if ($processing = $this->processingInstructions($token, count($this->rules)+$indexStart)) {
51 56
 				$this->rules = array_merge($this->rules, $processing);
52 57
 				continue;
53
-			}
54
-			else if ($token['type'] === Tokenizer::NEW_LINE) {
58
+			} else if ($token['type'] === Tokenizer::NEW_LINE) {
55 59
 				$line++;
56 60
 				continue;
61
+			} else {
62
+				$this->addRules($token, $indexStart, $line);
57 63
 			}
58
-			else $this->addRules($token, $indexStart, $line);
59 64
 		}
60 65
 		return $this->rules;
61 66
 	}
@@ -63,14 +68,18 @@  discard block
 block discarded – undo
63 68
 	private function addRules($token, $indexStart, $line) {
64 69
 		$selector = $this->tss->from($token['type'], true)->to(Tokenizer::OPEN_BRACE);
65 70
 		$this->tss->skip(count($selector));
66
-		if (count($selector) === 0) return;
71
+		if (count($selector) === 0) {
72
+			return;
73
+		}
67 74
 
68 75
 		$newRules = $this->cssToRules($selector, count($this->rules)+$indexStart, $this->getProperties($this->tss->current()['value']), $line);
69 76
 		$this->rules = $this->writeRule($this->rules, $newRules);
70 77
 	}
71 78
 
72 79
 	private function checkError($rules) {
73
-		if (empty($rules) && count($this->tss) > 0) throw new \Exception('No TSS rules parsed');
80
+		if (empty($rules) && count($this->tss) > 0) {
81
+			throw new \Exception('No TSS rules parsed');
82
+		}
74 83
 	}
75 84
 
76 85
 	private function CssToRules($selector, $index, $properties, $line) {
@@ -97,7 +106,9 @@  discard block
 block discarded – undo
97 106
 	}
98 107
 
99 108
 	private function processingInstructions($token, $indexStart) {
100
-		if ($token['type'] !== Tokenizer::AT_SIGN) return false;
109
+		if ($token['type'] !== Tokenizer::AT_SIGN) {
110
+			return false;
111
+		}
101 112
 		$tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false);
102 113
 		$funcName = $tokens->from(Tokenizer::NAME, true)->read();
103 114
 		$args = $this->valueParser->parseTokens($tokens->from(Tokenizer::NAME));
@@ -109,8 +120,11 @@  discard block
 block discarded – undo
109 120
 	}
110 121
 
111 122
 	private function import($args, $indexStart) {
112
-		if ($this->file !== null) $fileName = $fileName = $this->filePath->getFilePath($args[0]);
113
-		else $fileName = $args[0];
123
+		if ($this->file !== null) {
124
+			$fileName = $fileName = $this->filePath->getFilePath($args[0]);
125
+		} else {
126
+			$fileName = $args[0];
127
+		}
114 128
 		$this->import[] = $fileName;
115 129
 		$baseDirTemp = $this->filePath->getFilePath();
116 130
 		$sheet = new Sheet($fileName, $this->xPath, $this->valueParser, $this->cache, $this->filePath);
@@ -120,7 +134,9 @@  discard block
 block discarded – undo
120 134
 
121 135
 	private function sortRules($a, $b) {
122 136
 		//If they have the same depth, compare on index
123
-		if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1;
137
+		if ($a->depth === $b->depth) {
138
+			return $a->index < $b->index ? -1 : 1;
139
+		}
124 140
 
125 141
 		return ($a->depth < $b->depth) ? -1 : 1;
126 142
 	}
@@ -129,7 +145,9 @@  discard block
 block discarded – undo
129 145
 		$pos = 0;
130 146
 		while (($pos = strpos($str, $open, $pos)) !== false) {
131 147
 			$end = strpos($str, $close, $pos);
132
-			if ($end === false) break;
148
+			if ($end === false) {
149
+				break;
150
+			}
133 151
 			$str = substr_replace($str, '', $pos, $end-$pos+strlen($close));
134 152
 		}
135 153
 
Please login to merge, or discard this patch.
src/Parser/CssToXpath.php 3 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,7 +69,9 @@  discard block
 block discarded – undo
69 69
 				$selector->type = $token['type'];
70 70
 				$selectors[] = $selector;
71 71
 			}
72
-			if (isset($token['value'])) $selectors[count($selectors)-1]->string = $token['value'];
72
+			if (isset($token['value'])) {
73
+				$selectors[count($selectors)-1]->string = $token['value'];
74
+			}
73 75
 		}
74 76
 		return $selectors;
75 77
 	}
@@ -79,7 +81,9 @@  discard block
 block discarded – undo
79 81
 		$selectors = $this->split($css);
80 82
 		$xpath = '/';
81 83
 		foreach ($selectors as $selector) {
82
-			if (isset($this->translators[$selector->type])) $xpath .= $this->translators[$selector->type]($selector->string, $xpath);
84
+			if (isset($this->translators[$selector->type])) {
85
+				$xpath .= $this->translators[$selector->type]($selector->string, $xpath);
86
+			}
83 87
 		}
84 88
 
85 89
 		$xpath = str_replace('/[', '/*[', $xpath);
@@ -90,7 +94,9 @@  discard block
 block discarded – undo
90 94
 	private function removeSpacesFromDirectDecend($css) {
91 95
 		$tokens = [];
92 96
 		foreach ($css->splitOnToken(Tokenizer::GREATER_THAN) as $token) {
93
-			foreach ($token->trim() as $t) $tokens[]  = $t;
97
+			foreach ($token->trim() as $t) {
98
+				$tokens[]  = $t;
99
+			}
94 100
 			$tokens[] = ['type' => Tokenizer::GREATER_THAN];
95 101
 		}
96 102
 		return new Tokens(array_slice($tokens, 0, -1));
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@
 block discarded – undo
43 43
 		$functionSet->setElement($element[0]);
44 44
 
45 45
 		$attributes = array();
46
-        foreach($element[0]->attributes as $attribute_name => $attribute_node) {
47
-            $attributes[$attribute_name] = $attribute_node->nodeValue;
48
-        }	
46
+		foreach($element[0]->attributes as $attribute_name => $attribute_node) {
47
+			$attributes[$attribute_name] = $attribute_node->nodeValue;
48
+		}	
49 49
 
50
-        $parser = new \Transphporm\Parser\Value($functionSet, true);
50
+		$parser = new \Transphporm\Parser\Value($functionSet, true);
51 51
 		$return = $parser->parseTokens($attr, $attributes);
52 52
 
53 53
 		return $return[0] === '' ? false : $return[0];
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 		$this->functionSet = $functionSet;
20 20
 
21 21
 		$this->translators = [
22
-			Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//' . $prefix . $string;	},
23
-			'' => function($string) use ($prefix) { return '/' . $prefix . $string;	},
24
-			Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/' . $prefix  . $string; },
25
-			Tokenizer::NUM_SIGN => function($string) { return '[@id=\'' . $string . '\']'; },
26
-			Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' ' . $string . ' \')]'; },
27
-			Tokenizer::OPEN_SQUARE_BRACKET => function($string) use ($hash) { return '[' .'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \'' . base64_encode(serialize($string)) . '\', ., "' . $hash . '")' . ']';	}
22
+			Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//'.$prefix.$string; },
23
+			'' => function($string) use ($prefix) { return '/'.$prefix.$string; },
24
+			Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/'.$prefix.$string; },
25
+			Tokenizer::NUM_SIGN => function($string) { return '[@id=\''.$string.'\']'; },
26
+			Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' '.$string.' \')]'; },
27
+			Tokenizer::OPEN_SQUARE_BRACKET => function($string) use ($hash) { return '['.'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \''.base64_encode(serialize($string)).'\', ., "'.$hash.'")'.']'; }
28 28
 		];
29 29
 	}
30 30
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		$functionSet->setElement($element[0]);
44 44
 
45 45
 		$attributes = array();
46
-        foreach($element[0]->attributes as $attribute_name => $attribute_node) {
46
+        foreach ($element[0]->attributes as $attribute_name => $attribute_node) {
47 47
             $attributes[$attribute_name] = $attribute_node->nodeValue;
48 48
         }	
49 49
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	private function removeSpacesFromDirectDecend($css) {
91 91
 		$tokens = [];
92 92
 		foreach ($css->splitOnToken(Tokenizer::GREATER_THAN) as $token) {
93
-			foreach ($token->trim() as $t) $tokens[]  = $t;
93
+			foreach ($token->trim() as $t) $tokens[] = $t;
94 94
 			$tokens[] = ['type' => Tokenizer::GREATER_THAN];
95 95
 		}
96 96
 		return new Tokens(array_slice($tokens, 0, -1));
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
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 
52 52
 		$cachedOutput = $this->loadTemplate();
53 53
 		//To be a valid XML document it must have a root element, automatically wrap it in <template> to ensure it does
54
-		$template = new Template($this->isValidDoc($cachedOutput['body']) ? str_ireplace('<!doctype', '<!DOCTYPE', $cachedOutput['body']) : '<template>' . $cachedOutput['body'] . '</template>' );
54
+		$template = new Template($this->isValidDoc($cachedOutput['body']) ? str_ireplace('<!doctype', '<!DOCTYPE', $cachedOutput['body']) : '<template>'.$cachedOutput['body'].'</template>');
55 55
 		$valueParser = new Parser\Value($functionSet);
56 56
 		$config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix()), new FilePath($this->rootDir), $headers);
57 57
 
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		$this->cache = new Cache(new \ArrayObject());
27 27
 
28 28
 		$modules = is_array($modules) ? $modules : $this->defaultModules;
29
-		foreach ($modules as $module) $this->loadModule(new $module);
29
+		foreach ($modules as $module) {
30
+			$this->loadModule(new $module);
31
+		}
30 32
 	}
31 33
 
32 34
 	//Allow setting the time used by Transphporm for caching. This is for testing purposes
@@ -55,7 +57,9 @@  discard block
 block discarded – undo
55 57
 		$valueParser = new Parser\Value($functionSet);
56 58
 		$config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix()), new FilePath($this->rootDir), $headers);
57 59
 
58
-		foreach ($this->modules as $module) $module->load($config);
60
+		foreach ($this->modules as $module) {
61
+			$module->load($config);
62
+		}
59 63
 
60 64
 		$this->processRules($template, $config);
61 65
 
@@ -70,7 +74,9 @@  discard block
 block discarded – undo
70 74
 		$rules = $this->getRules($template, $config);
71 75
 
72 76
 		foreach ($rules as $rule) {
73
-			if ($rule->shouldRun($this->time)) $this->executeTssRule($rule, $template, $config);
77
+			if ($rule->shouldRun($this->time)) {
78
+				$this->executeTssRule($rule, $template, $config);
79
+			}
74 80
 		}
75 81
 	}
76 82
 
@@ -95,8 +101,9 @@  discard block
 block discarded – undo
95 101
 		if (trim($this->template)[0] !== '<') {
96 102
 			$xml = $this->cache->load($this->template, filemtime($this->template));
97 103
 			return $xml ? $xml : ['body' => file_get_contents($this->template), 'headers' => []];
104
+		} else {
105
+			return ['body' => $this->template, 'headers' => []];
98 106
 		}
99
-		else return ['body' => $this->template, 'headers' => []];
100 107
 	}
101 108
 
102 109
 	//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/TSSCache.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm;
3 3
 class TSSCache {
4
-    private $cache;
5
-    private $prefix;
4
+	private $cache;
5
+	private $prefix;
6 6
 
7
-    public function __construct(Cache $cache, $prefix) {
8
-        $this->cache = $cache;
9
-        $this->prefix = $prefix;
10
-    }
7
+	public function __construct(Cache $cache, $prefix) {
8
+		$this->cache = $cache;
9
+		$this->prefix = $prefix;
10
+	}
11 11
 
12 12
 	private function getRulesFromCache($file) {
13 13
 		//The cache for the key: the filename and template prefix
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 		return $file . $this->prefix . dirname(realpath($file)) . DIRECTORY_SEPARATOR;
29 29
 	}
30 30
 
31
-    public function load($tss) {
32
-        return $this->getRulesFromCache($tss);
33
-    }
31
+	public function load($tss) {
32
+		return $this->getRulesFromCache($tss);
33
+	}
34 34
 
35
-    public function write($file, $rules, $imports = []) {
36
-        if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
37
-        return $rules;
38
-    }
35
+	public function write($file, $rules, $imports = []) {
36
+		if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
37
+		return $rules;
38
+	}
39 39
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 	}
26 26
 
27 27
 	private function getCacheKey($file) {
28
-		return $file . $this->prefix . dirname(realpath($file)) . DIRECTORY_SEPARATOR;
28
+		return $file.$this->prefix.dirname(realpath($file)).DIRECTORY_SEPARATOR;
29 29
 	}
30 30
 
31 31
     public function load($tss) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 		$rules = $this->cache->load($key, filemtime($file));
19 19
 		if ($rules) {
20 20
 			foreach ($rules['import'] as $file) {
21
-				if (!$this->cache->load($this->getCacheKey($file), filemtime($file))) return false;
21
+				if (!$this->cache->load($this->getCacheKey($file), filemtime($file))) {
22
+					return false;
23
+				}
22 24
 			}
23 25
 		}
24 26
 		return $rules;
@@ -33,7 +35,9 @@  discard block
 block discarded – undo
33 35
     }
34 36
 
35 37
     public function write($file, $rules, $imports = []) {
36
-        if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
38
+        if (is_file($file)) {
39
+        	$this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
40
+        }
37 41
         return $rules;
38 42
     }
39 43
 }
Please login to merge, or discard this patch.
src/TSSFunction/Template.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -17,6 +17,9 @@
 block discarded – undo
17 17
 		$this->xPath = $xPath;
18 18
 	}
19 19
 
20
+	/**
21
+	 * @param integer $index
22
+	 */
20 23
 	private function readArray($array, $index) {
21 24
 		return isset($array[$index]) ? $array[$index] : null;
22 25
 	}
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 	private function getTemplateContent($newNode, $tss) {
41 41
 		$result = [];
42 42
 		foreach ($newNode->childNodes as $node) {
43
-            if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss);
43
+			if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss);
44 44
 			else $result[] = $this->getClonedElement($node, $tss);
45 45
 		}
46 46
 		return $result;
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,13 +25,18 @@  discard block
 block discarded – undo
25 25
 		$selector = $this->readArray($args, 1);
26 26
 		$tss = $this->readArray($args, 2);
27 27
 
28
-		if (trim($args[0])[0] === '<') $xml = $args[0];
29
-		else $xml = $this->filePath->getFilePath($args[0]);
28
+		if (trim($args[0])[0] === '<') {
29
+			$xml = $args[0];
30
+		} else {
31
+			$xml = $this->filePath->getFilePath($args[0]);
32
+		}
30 33
 
31 34
 		$newTemplate = new \Transphporm\Builder($xml, $tss ? $this->filePath->getFilePath($tss) : null);
32 35
 
33 36
 		$doc = $newTemplate->output($this->elementData->getData($element), true)->body;
34
-		if ($selector != '') return $this->templateSubsection($doc, $selector);
37
+		if ($selector != '') {
38
+			return $this->templateSubsection($doc, $selector);
39
+		}
35 40
 
36 41
 		return $this->getTemplateContent($doc->documentElement, $tss);
37 42
 
@@ -40,8 +45,11 @@  discard block
 block discarded – undo
40 45
 	private function getTemplateContent($newNode, $tss) {
41 46
 		$result = [];
42 47
 		foreach ($newNode->childNodes as $node) {
43
-            if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss);
44
-			else $result[] = $this->getClonedElement($node, $tss);
48
+            if (isset($node->tagName) && $node->tagName === 'template') {
49
+            	$result[] = $this->getTemplateContent($node, $tss);
50
+            } else {
51
+				$result[] = $this->getClonedElement($node, $tss);
52
+			}
45 53
 		}
46 54
 		return $result;
47 55
 	}
@@ -60,7 +68,9 @@  discard block
 block discarded – undo
60 68
 
61 69
 	private function getClonedElement($node, $tss) {
62 70
 		$clone = $node->cloneNode(true);
63
-		if ($tss != null && $clone instanceof \DomElement) $clone->setAttribute('transphporm', 'includedtemplate');
71
+		if ($tss != null && $clone instanceof \DomElement) {
72
+			$clone->setAttribute('transphporm', 'includedtemplate');
73
+		}
64 74
 		return $clone;
65 75
 	}
66 76
 }
Please login to merge, or discard this patch.