Completed
Push — master ( 5d19ef...aa44e7 )
by Tom
02:20
created
src/Formatter/Date.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/** Converts $val into a \DateTime object if it's not already */
12 12
 	private function getDate($val) {
13 13
 		$tz = new \DateTimeZone($this->locale['timezone']);
14
-		$date =  $val instanceof \DateTime ? $val : new \DateTime($val, $tz);
14
+		$date = $val instanceof \DateTime ? $val : new \DateTime($val, $tz);
15 15
 		$date->setTimeZone($tz);
16 16
 		return $date;
17 17
 	}
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 	/** Formats \DateTime as Date and Time using formats from $locale */
32 32
 	public function dateTime($val) {
33
-		return $this->date($val, $this->locale['date_format'] . ' ' . $this->locale['time_format']);
33
+		return $this->date($val, $this->locale['date_format'].' '.$this->locale['time_format']);
34 34
 	}
35 35
 
36 36
 	/** Generates relative time offsets based on system clock. e.g "10 minutes ago" or "In 6 months"
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		$diff = $now->diff($date);
43 43
 
44 44
 
45
-		$diffDays = $diff->invert === 1 ? $diff->days : 0- $diff->days;
45
+		$diffDays = $diff->invert === 1 ? $diff->days : 0-$diff->days;
46 46
 
47 47
 		if ($diffDays !== 0) return $this->dayOffset($diffDays);
48 48
 		else return $this->timeOffset($diff);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
 	/** Gets date ranges to represent uses of weeks/months/days/etc */
70 70
 	private function getRanges($strings) {
71
-		$ranges =  [
71
+		$ranges = [
72 72
 			[1, 1, $strings['yesterday'], 1, ''],
73 73
 			[1, 13, $strings['past'], 1, 'days'],
74 74
 			[13, 28, $strings['past'], 7, 'weeks'],
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
 	/** Converts "week" to "weeks", "month" to "months" etc when plural is required using language from $locale */
89 89
 	private function getPlural($strings, $num, $interval) {
90
-		if ($interval !== '') return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural'];
90
+		if ($interval !== '') return $num == 1 ? $strings[$interval.'_singular'] : $strings[$interval.'_plural'];
91 91
 		else return '';
92 92
 	}
93 93
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,8 +44,11 @@  discard block
 block discarded – undo
44 44
 
45 45
 		$diffDays = $diff->invert === 1 ? $diff->days : 0- $diff->days;
46 46
 
47
-		if ($diffDays !== 0) return $this->dayOffset($diffDays);
48
-		else return $this->timeOffset($diff);
47
+		if ($diffDays !== 0) {
48
+			return $this->dayOffset($diffDays);
49
+		} else {
50
+			return $this->timeOffset($diff);
51
+		}
49 52
 	}
50 53
 
51 54
 	/** Calculates offset in hours/minutes/seconds */
@@ -80,15 +83,22 @@  discard block
 block discarded – undo
80 83
 			[-365, -28, $strings['future'], 28, 'months'],
81 84
 			[-999999, -365, $strings['future'], 365, 'years'],
82 85
 		];
83
-		if (isset($strings['day_before_yesterday'])) array_unshift($ranges, [2, 2, $strings['day_before_yesterday'], 1, '']);
84
-		if (isset($strings['day_after_tomorrow'])) array_unshift($ranges, [-2, -2, $strings['day_after_tomorrow'], 1, '']);
86
+		if (isset($strings['day_before_yesterday'])) {
87
+			array_unshift($ranges, [2, 2, $strings['day_before_yesterday'], 1, '']);
88
+		}
89
+		if (isset($strings['day_after_tomorrow'])) {
90
+			array_unshift($ranges, [-2, -2, $strings['day_after_tomorrow'], 1, '']);
91
+		}
85 92
 		return $ranges;
86 93
 	}
87 94
 
88 95
 	/** Converts "week" to "weeks", "month" to "months" etc when plural is required using language from $locale */
89 96
 	private function getPlural($strings, $num, $interval) {
90
-		if ($interval !== '') return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural'];
91
-		else return '';
97
+		if ($interval !== '') {
98
+			return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural'];
99
+		} else {
100
+			return '';
101
+		}
92 102
 	}
93 103
 
94 104
 	/** Calculates offset in days/weeks/month/years */
Please login to merge, or discard this patch.
src/Formatter/Number.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 
14 14
 	public function currency($num) {
15 15
 		$num = $this->decimal($num, $this->locale['currency_decimals']);
16
-		if ($this->locale['currency_position'] === 'before') return $this->locale['currency'] . $num;
17
-		else return $num . $this->locale['currency'];
16
+		if ($this->locale['currency_position'] === 'before') return $this->locale['currency'].$num;
17
+		else return $num.$this->locale['currency'];
18 18
 	}
19 19
 }
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,10 @@
 block discarded – undo
13 13
 
14 14
 	public function currency($num) {
15 15
 		$num = $this->decimal($num, $this->locale['currency_decimals']);
16
-		if ($this->locale['currency_position'] === 'before') return $this->locale['currency'] . $num;
17
-		else return $num . $this->locale['currency'];
16
+		if ($this->locale['currency_position'] === 'before') {
17
+			return $this->locale['currency'] . $num;
18
+		} else {
19
+			return $num . $this->locale['currency'];
20
+		}
18 21
 	}
19 22
 }
20 23
\ No newline at end of file
Please login to merge, or discard this patch.
src/Rule.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@
 block discarded – undo
39 39
 		$num = (int) $frequency;
40 40
 		$unit = strtoupper(trim(str_replace($num, '', $frequency)));
41 41
 			
42
-		$offset = $num * constant(self::class . '::' . $unit);
42
+		$offset = $num * constant(self::class.'::'.$unit);
43 43
 
44
-		if ($time > $this->lastRun + $offset) return true;
44
+		if ($time > $this->lastRun+$offset) return true;
45 45
 		else return false;
46 46
 	}
47 47
 
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	private $pseudo;
11 11
 	private $depth;
12 12
 	private $index;
13
-    private $file;
13
+	private $file;
14 14
 	private $line;
15 15
 	private $properties = [];
16 16
 	private $lastRun = 0;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		$this->pseudo = $pseudo;
27 27
 		$this->depth = $depth;
28 28
 		$this->index = $index;
29
-        $this->file = $file;
29
+		$this->file = $file;
30 30
 		$this->line = $line;
31 31
 		$this->properties = $properties;
32 32
 	}
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,23 +44,32 @@
 block discarded – undo
44 44
 	}
45 45
 
46 46
 	private function timeFrequency($frequency, $time = null) {
47
-		if ($time === null) $time = time();
47
+		if ($time === null) {
48
+			$time = time();
49
+		}
48 50
 		$num = (int) $frequency;
49 51
 		$unit = strtoupper(trim(str_replace($num, '', $frequency)));
50 52
 
51 53
 		$offset = $num * constant(self::class . '::' . $unit);
52 54
 
53
-		if ($time > $this->lastRun + $offset) return true;
54
-		else return false;
55
+		if ($time > $this->lastRun + $offset) {
56
+			return true;
57
+		} else {
58
+			return false;
59
+		}
55 60
 	}
56 61
 
57 62
 	public function shouldRun($time = null) {
58 63
 		if (isset($this->properties['update-frequency']) && $this->lastRun !== 0) {
59 64
 			$frequency = $this->properties['update-frequency']->read();
60 65
 			$static = ['always' => true, 'never' => false];
61
-			if (isset($static[$frequency])) return $static[$frequency];
62
-			else return $this->timeFrequency($frequency, $time);
66
+			if (isset($static[$frequency])) {
67
+				return $static[$frequency];
68
+			} else {
69
+				return $this->timeFrequency($frequency, $time);
70
+			}
71
+		} else {
72
+			return true;
63 73
 		}
64
-		else return true;
65 74
 	}
66 75
 }
Please login to merge, or discard this patch.
src/Hook/PostProcess.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,9 +9,13 @@
 block discarded – undo
9 9
 class PostProcess implements \Transphporm\Hook {
10 10
 	public function run(\DomElement $element) {
11 11
 		$transphporm = $element->getAttribute('transphporm');
12
-		if ($transphporm === 'remove') $element->parentNode->removeChild($element);
13
-		else if ($transphporm === 'text') $element->parentNode->replaceChild($element->firstChild, $element);
14
-		else $element->removeAttribute('transphporm');
12
+		if ($transphporm === 'remove') {
13
+			$element->parentNode->removeChild($element);
14
+		} else if ($transphporm === 'text') {
15
+			$element->parentNode->replaceChild($element->firstChild, $element);
16
+		} else {
17
+			$element->removeAttribute('transphporm');
18
+		}
15 19
 	}
16 20
 
17 21
 }
18 22
\ No newline at end of file
Please login to merge, or discard this patch.
src/Hook/ElementData.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@
 block discarded – undo
31 31
 	/** Returns the data that has been bound to $element, or, if no data is bound to $element climb the DOM tree to find the data bound to a parent node*/
32 32
 	public function getData(\DomElement $element = null, $type = 'data') {
33 33
 		while ($element) {
34
-			if (isset($this->elementMap[$element]) && isset($this->elementMap[$element][$type])) return $this->elementMap[$element][$type];
34
+			if (isset($this->elementMap[$element]) && isset($this->elementMap[$element][$type])) {
35
+				return $this->elementMap[$element][$type];
36
+			}
35 37
 			$element = $element->parentNode;
36 38
 		}
37 39
 		return $this->data;
Please login to merge, or discard this patch.
src/Parser/Tokenizer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
 			$string = $this->extractString($i);
106 106
 			$length = strlen($string)+1;
107 107
 			$char = $this->getChar($char);
108
-			$string = str_replace('\\' . $char, $char, $string);
108
+			$string = str_replace('\\'.$char, $char, $string);
109 109
 			$tokens[] = ['type' => self::STRING, 'value' => $string];
110 110
 			return $length;
111 111
 		}
Please login to merge, or discard this patch.
Braces   +30 added lines, -12 removed lines patch added patch discarded remove patch
@@ -76,8 +76,11 @@  discard block
 block discarded – undo
76 76
 			$i += $this->doStrings($tokens, $char, $i);
77 77
 			$i += $this->doBrackets($tokens, $char, $i);
78 78
 		}
79
-		if ($returnObj) return new Tokens($tokens);
80
-		else return $tokens;
79
+		if ($returnObj) {
80
+			return new Tokens($tokens);
81
+		} else {
82
+			return $tokens;
83
+		}
81 84
 	}
82 85
 
83 86
 	private function doSimpleTokens(&$tokens, $char) {
@@ -107,10 +110,15 @@  discard block
 block discarded – undo
107 110
 	}
108 111
 
109 112
 	private function processLiterals(&$tokens, $name) {
110
-		if (is_numeric($name)) $tokens[] = ['type' => self::NUMERIC, 'value' => $name];
111
-		else if ($name == 'true') $tokens[] = ['type' => self::BOOL, 'value' => true];
112
-		else if ($name == 'false') $tokens[] = ['type' => self::BOOL, 'value' => false];
113
-		else $tokens[] = ['type' => self::NAME, 'value' => $name];
113
+		if (is_numeric($name)) {
114
+			$tokens[] = ['type' => self::NUMERIC, 'value' => $name];
115
+		} else if ($name == 'true') {
116
+			$tokens[] = ['type' => self::BOOL, 'value' => true];
117
+		} else if ($name == 'false') {
118
+			$tokens[] = ['type' => self::BOOL, 'value' => false];
119
+		} else {
120
+			$tokens[] = ['type' => self::NAME, 'value' => $name];
121
+		}
114 122
 	}
115 123
 
116 124
 	private function doBrackets(&$tokens, $char, $i) {
@@ -144,7 +152,9 @@  discard block
 block discarded – undo
144 152
 	private function extractString($pos) {
145 153
 		$char = $this->str[$pos];
146 154
 		$end = strpos($this->str, $char, $pos+1);
147
-		while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1);
155
+		while ($end !== false && $this->str[$end-1] == '\\') {
156
+			$end = strpos($this->str, $char, $end+1);
157
+		}
148 158
 
149 159
 		return substr($this->str, $pos+1, $end-$pos-1);
150 160
 	}
@@ -153,18 +163,26 @@  discard block
 block discarded – undo
153 163
 		$close = strpos($this->str, $closeBracket, $open);
154 164
 
155 165
 		$cPos = $open+1;
156
-		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closeBracket, $close+1);
166
+		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) {
167
+			$close = strpos($this->str, $closeBracket, $close+1);
168
+		}
157 169
 		return substr($this->str, $open+1, $close-$open-1);
158 170
 	}
159 171
 
160 172
 	private function identifyChar($chr) {
161
-		if (isset($this->chars[$chr])) return $this->chars[$chr];
162
-		else return self::NAME;
173
+		if (isset($this->chars[$chr])) {
174
+			return $this->chars[$chr];
175
+		} else {
176
+			return self::NAME;
177
+		}
163 178
 	}
164 179
 
165 180
 	private function getChar($num) {
166 181
 		$chars = array_reverse($this->chars);
167
-		if (isset($chars[$num])) return $chars[$num];
168
-		else return false;
182
+		if (isset($chars[$num])) {
183
+			return $chars[$num];
184
+		} else {
185
+			return false;
186
+		}
169 187
 	}
170 188
 }
Please login to merge, or discard this patch.
src/TSSFunction/Data.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @version         1.0                                                             */
7 7
 namespace Transphporm\TSSFunction;
8 8
 /* Handles data() and iteration() function calls from the stylesheet */
9
-class Data implements \Transphporm\TSSFunction{
9
+class Data implements \Transphporm\TSSFunction {
10 10
 	private $data;
11 11
 	private $dataKey;
12 12
 	private $functionSet;
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,11 @@
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	public function run(array $args, \DomElement $element = null) {
21
-		if ($this->dataKey === "root") $data = $this->data->getData(null, 'data');
22
-		else $data = $this->data->getData($element, $this->dataKey);
21
+		if ($this->dataKey === "root") {
22
+			$data = $this->data->getData(null, 'data');
23
+		} else {
24
+			$data = $this->data->getData($element, $this->dataKey);
25
+		}
23 26
 		$parser = new \Transphporm\Parser\Value($this->functionSet, true, true);
24 27
 		$return = $parser->parseTokens(new \Transphporm\Parser\Tokens($args), $data);
25 28
 		return $return[0];
Please login to merge, or discard this patch.
src/Pseudo/Not.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 	}
17 17
 
18 18
 	public function match($name, $args, \DomElement $element) {
19
-		if ($name !== 'not') return true;
19
+		if ($name !== 'not') {
20
+			return true;
21
+		}
20 22
 		
21 23
 		$xpath = new \DomXpath($element->ownerDocument);
22 24
 		return $this->notElement($args, $xpath, $element);
@@ -29,7 +31,9 @@  discard block
 block discarded – undo
29 31
 			//Find all nodes matched by the expressions in the brackets :not(EXPR)
30 32
 			foreach ($xpath->query($xpathString) as $matchedElement) {
31 33
 				//Check to see whether this node was matched by the not query
32
-				if ($element->isSameNode($matchedElement)) return false;
34
+				if ($element->isSameNode($matchedElement)) {
35
+					return false;
36
+				}
33 37
 			}
34 38
 		}
35 39
 		return true;
Please login to merge, or discard this patch.
src/Parser/CssToXpath.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@
 block discarded – undo
49 49
 		$functionSet->setElement($element[0]);
50 50
 
51 51
 		$attributes = array();
52
-        foreach($element[0]->attributes as $attribute_name => $attribute_node) {
53
-            $attributes[$attribute_name] = $attribute_node->nodeValue;
54
-        }
52
+		foreach($element[0]->attributes as $attribute_name => $attribute_node) {
53
+			$attributes[$attribute_name] = $attribute_node->nodeValue;
54
+		}
55 55
 
56
-        $parser = new \Transphporm\Parser\Value($functionSet, true);
56
+		$parser = new \Transphporm\Parser\Value($functionSet, true);
57 57
 		$return = $parser->parseTokens($attr, $attributes);
58 58
 
59 59
 		return $return[0] === '' ? false : $return[0];
Please login to merge, or discard this patch.
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.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 		$this->functionSet = $functionSet;
19 19
 
20 20
 		$this->translators = [
21
-			Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//' . $prefix . $string;	},
22
-			'' => function($string) use ($prefix) { return '/' . $prefix . $string;	},
23
-			Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/' . $prefix  . $string; },
24
-			Tokenizer::NUM_SIGN => function($string) { return '[@id=\'' . $string . '\']'; },
25
-			Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' ' . $string . ' \')]'; },
26
-			Tokenizer::OPEN_SQUARE_BRACKET => function($string) use ($hash) { return '[' .'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \'' . base64_encode(serialize($string)) . '\', ., "' . $hash . '")' . ']';	}
21
+			Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//'.$prefix.$string; },
22
+			'' => function($string) use ($prefix) { return '/'.$prefix.$string; },
23
+			Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/'.$prefix.$string; },
24
+			Tokenizer::NUM_SIGN => function($string) { return '[@id=\''.$string.'\']'; },
25
+			Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' '.$string.' \')]'; },
26
+			Tokenizer::OPEN_SQUARE_BRACKET => function($string) use ($hash) { return '['.'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \''.base64_encode(serialize($string)).'\', ., "'.$hash.'")'.']'; }
27 27
 		];
28 28
 	}
29 29
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$functionSet->setElement($element[0]);
48 48
 
49 49
 		$attributes = array();
50
-        foreach($element[0]->attributes as $attribute_name => $attribute_node) {
50
+        foreach ($element[0]->attributes as $attribute_name => $attribute_node) {
51 51
             $attributes[$attribute_name] = $attribute_node->nodeValue;
52 52
         }
53 53
 
@@ -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.