Completed
Push — master ( 9d6d2c...15e885 )
by Tom
02:32
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/Template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 		if ($document) return $this->document;
56 56
 
57 57
 
58
-		$output = ($this->document->doctype) ? $this->document->saveXml($this->document->doctype) . "\n" : '';
58
+		$output = ($this->document->doctype) ? $this->document->saveXml($this->document->doctype)."\n" : '';
59 59
 
60 60
 		if ($this->document->documentElement->tagName !== 'template') $output .= $this->document->saveXml($this->document->documentElement, LIBXML_NOEMPTYTAG);
61 61
 		else $output = $this->printDocument($this->document);
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,8 +35,9 @@  discard block
 block discarded – undo
35 35
 				$htmlDoc = new \DomDocument;
36 36
 				$htmlDoc->loadHtml($doc);
37 37
 				
38
-				if (strpos($doc, '<!') === 0) $this->document = $htmlDoc;
39
-				else {
38
+				if (strpos($doc, '<!') === 0) {
39
+					$this->document = $htmlDoc;
40
+				} else {
40 41
 					$templateNode = $htmlDoc->getElementsByTagName('template')[0];
41 42
 					$this->document->appendChild($this->document->importNode($templateNode, true));
42 43
 				}
@@ -57,7 +58,9 @@  discard block
 block discarded – undo
57 58
 	/** Loops through all assigned hooks, runs the Xpath query and calls the hook */
58 59
 	private function processHooks() {
59 60
 		foreach ($this->hooks as list($query, $hook)) {
60
-			foreach ($this->xpath->query($query) as $element) $hook->run($element);
61
+			foreach ($this->xpath->query($query) as $element) {
62
+				$hook->run($element);
63
+			}
61 64
 		}
62 65
 		$this->hooks = [];
63 66
 	}
@@ -65,7 +68,9 @@  discard block
 block discarded – undo
65 68
 	/** Prints out the current DomDocument as HTML */
66 69
 	private function printDocument(\DomDocument $doc) {
67 70
 		$output = '';
68
-		foreach ($doc->documentElement->childNodes as $node) $output .= $doc->saveXML($node, LIBXML_NOEMPTYTAG);
71
+		foreach ($doc->documentElement->childNodes as $node) {
72
+			$output .= $doc->saveXML($node, LIBXML_NOEMPTYTAG);
73
+		}
69 74
 		return $output;
70 75
 	}
71 76
 
@@ -77,13 +82,18 @@  discard block
 block discarded – undo
77 82
 		//Generate the document by taking only the childnodes of the template, ignoring the <template> and </template> tags
78 83
 		//TODO: Is there a faster way of doing this without string manipulation on the output or this loop through childnodes?
79 84
 		 //Either return a whole DomDocument or return the output HTML
80
-		if ($document) return $this->document;
85
+		if ($document) {
86
+			return $this->document;
87
+		}
81 88
 
82 89
 
83 90
 		$output = ($this->document->doctype) ? $this->document->saveXml($this->document->doctype) . "\n" : '';
84 91
 
85
-		if ($this->document->documentElement->tagName !== 'template') $output .= $this->document->saveXml($this->document->documentElement, LIBXML_NOEMPTYTAG);
86
-		else $output = $this->printDocument($this->document);
92
+		if ($this->document->documentElement->tagName !== 'template') {
93
+			$output .= $this->document->saveXml($this->document->documentElement, LIBXML_NOEMPTYTAG);
94
+		} else {
95
+			$output = $this->printDocument($this->document);
96
+		}
87 97
 
88 98
 		//repair empty tags. Browsers break on <script /> and <div /> so can't avoid LIBXML_NOEMPTYTAG but they also break on <base></base> so repair them
89 99
 		$output = str_replace(['></img>', '></br>', '></meta>', '></base>', '></link>', '></hr>', '></input>'], ' />', $output);
Please login to merge, or discard this patch.
src/Cache.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
20 20
 	public function load($key, $modified = 0) {
21 21
 		if (isset($this->cache[$key]) && $this->cache[$key]['timestamp'] >= $modified) {
22 22
 			return $this->cache[$key]['content'];
23
+		} else {
24
+			return false;
23 25
 		}
24
-		else return false;
25 26
 	}
26 27
 }
27 28
\ No newline at end of file
Please login to merge, or discard this patch.
src/Rule.php 2 patches
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,24 +35,33 @@
 block discarded – undo
35 35
 	}
36 36
 
37 37
 	private function timeFrequency($frequency, $time = null) {
38
-		if ($time === null) $time = time();
38
+		if ($time === null) {
39
+			$time = time();
40
+		}
39 41
 		$num = (int) $frequency;
40 42
 		$unit = strtoupper(trim(str_replace($num, '', $frequency)));
41 43
 			
42 44
 		$offset = $num * constant(self::class . '::' . $unit);
43 45
 
44
-		if ($time > $this->lastRun + $offset) return true;
45
-		else return false;
46
+		if ($time > $this->lastRun + $offset) {
47
+			return true;
48
+		} else {
49
+			return false;
50
+		}
46 51
 	}
47 52
 
48 53
 	public function shouldRun($time = null) {
49 54
 		if (isset($this->properties['update-frequency']) && $this->lastRun !== 0) {
50 55
 			$frequency = $this->properties['update-frequency'];
51 56
 			$static = ['always' => true, 'never' => false];
52
-			if (isset($static[$frequency])) return $static[$frequency];
53
-			else return $this->timeFrequency($frequency, $time);
57
+			if (isset($static[$frequency])) {
58
+				return $static[$frequency];
59
+			} else {
60
+				return $this->timeFrequency($frequency, $time);
61
+			}
54 62
 
63
+		} else {
64
+			return true;
55 65
 		}
56
-		else return true;
57 66
 	}
58 67
 }
59 68
\ No newline at end of file
Please login to merge, or discard this patch.
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.
src/Hook/Formatter.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,11 +8,15 @@
 block discarded – undo
8 8
 	}
9 9
 
10 10
 	public function format($value, $rules) {
11
-		if (!isset($rules['format'])) return $value;
11
+		if (!isset($rules['format'])) {
12
+			return $value;
13
+		}
12 14
 		$format = new \Transphporm\StringExtractor($rules['format']);
13 15
 		$options = explode(' ', $format);
14 16
 		$functionName = array_shift($options);
15
-		foreach ($options as &$f) $f = trim($format->rebuild($f), '"');
17
+		foreach ($options as &$f) {
18
+			$f = trim($format->rebuild($f), '"');
19
+		}
16 20
 
17 21
 		return $this->processFormat($options, $functionName, $value);		
18 22
 	}
Please login to merge, or discard this patch.
src/Parser/Sheet.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 			$selector = trim(substr($this->tss, $pos, $next-$pos));
30 30
 			$rule = $this->cssToRule($selector, count($rules));	
31
-			$pos =  strpos($this->tss, '}', $next)+1;
31
+			$pos = strpos($this->tss, '}', $next)+1;
32 32
 			$rule->properties = $this->getProperties(trim(substr($this->tss, $next+1, $pos-2-$next)));	
33 33
 			$rules = $this->writeRule($rules, $selector, $rule);
34 34
 		}
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	private function processingInstructions($tss, $pos, $next) {
55 55
 		$rules = [];
56 56
 		while (($atPos = strpos($tss, '@', $pos)) !== false) {
57
-			if ($atPos  <= (int) $next) {
57
+			if ($atPos <= (int) $next) {
58 58
 				$spacePos = strpos($tss, ' ', $atPos);
59 59
 				$funcName = substr($tss, $atPos+1, $spacePos-$atPos-1);
60 60
 				$pos = strpos($tss, ';', $spacePos);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	private function import($args) {
73
-		$sheet = new Sheet(file_get_contents($this->baseDir . trim($args, '\'" ')), $this->baseDir, $this->valueParser, $this->prefix);
73
+		$sheet = new Sheet(file_get_contents($this->baseDir.trim($args, '\'" ')), $this->baseDir, $this->valueParser, $this->prefix);
74 74
 		return $sheet->parse();
75 75
 	}
76 76
 
Please login to merge, or discard this patch.
Doc Comments   +19 added lines patch added patch discarded remove patch
@@ -12,6 +12,9 @@  discard block
 block discarded – undo
12 12
 	private $prefix;
13 13
 	private $valueParser;
14 14
 
15
+	/**
16
+	 * @param string $tss
17
+	 */
15 18
 	public function __construct($tss, $baseDir, Value $valueParser, $prefix = '') {
16 19
 		$this->tss = $this->stripComments($tss, '/*', '*/');
17 20
 		$this->tss = $this->stripComments($this->tss, '//', "\n");
@@ -38,6 +41,10 @@  discard block
 block discarded – undo
38 41
 		return $rules;
39 42
 	}
40 43
 
44
+	/**
45
+	 * @param string $selector
46
+	 * @param integer $index
47
+	 */
41 48
 	private function CssToRules($selector, $index, $properties) {
42 49
 		$parts = explode(',', $selector);
43 50
 		$rules = [];
@@ -60,6 +67,11 @@  discard block
 block discarded – undo
60 67
 		return $rules;
61 68
 	}
62 69
 
70
+	/**
71
+	 * @param integer $pos
72
+	 * @param integer $next
73
+	 * @param integer $indexStart
74
+	 */
63 75
 	private function processingInstructions($tss, $pos, $next, $indexStart) {
64 76
 		$rules = [];
65 77
 		while (($atPos = strpos($tss, '@', $pos)) !== false) {
@@ -90,6 +102,10 @@  discard block
 block discarded – undo
90 102
 		return ($a->depth < $b->depth) ? -1 : 1;
91 103
 	}
92 104
 
105
+	/**
106
+	 * @param string $open
107
+	 * @param string $close
108
+	 */
93 109
 	private function stripComments($str, $open, $close) {
94 110
 		$pos = 0;
95 111
 		while (($pos = strpos($str, $open, $pos)) !== false) {
@@ -100,6 +116,9 @@  discard block
 block discarded – undo
100 116
 		return $str;
101 117
 	}
102 118
 
119
+	/**
120
+	 * @param string $str
121
+	 */
103 122
 	private function getProperties($str) {
104 123
 		$stringExtractor = new StringExtractor($str);
105 124
 		$rules = explode(';', $stringExtractor);
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 			$rules = $this->writeRule($rules, $newRules);
34 34
 		}
35 35
 		//there may be processing instructions at the end
36
-		if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) $rules = array_merge($rules, $processing['rules']);
36
+		if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) {
37
+			$rules = array_merge($rules, $processing['rules']);
38
+		}
37 39
 		usort($rules, [$this, 'sortRules']);
38 40
 		return $rules;
39 41
 	}
@@ -69,8 +71,7 @@  discard block
 block discarded – undo
69 71
 				$pos = strpos($tss, ';', $spacePos);
70 72
 				$args = substr($tss, $spacePos+1, $pos-$spacePos-1);
71 73
 				$rules = array_merge($rules, $this->$funcName($args, $indexStart));
72
-			}
73
-			else {
74
+			} else {
74 75
 				break;	
75 76
 			} 
76 77
 		}
@@ -85,7 +86,9 @@  discard block
 block discarded – undo
85 86
 
86 87
 	private function sortRules($a, $b) {
87 88
 		//If they have the same depth, compare on index
88
-		if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1;
89
+		if ($a->depth === $b->depth) {
90
+			return $a->index < $b->index ? -1 : 1;
91
+		}
89 92
 
90 93
 		return ($a->depth < $b->depth) ? -1 : 1;
91 94
 	}
@@ -94,7 +97,9 @@  discard block
 block discarded – undo
94 97
 		$pos = 0;
95 98
 		while (($pos = strpos($str, $open, $pos)) !== false) {
96 99
 			$end = strpos($str, $close, $pos);
97
-			if ($end === false) break;
100
+			if ($end === false) {
101
+				break;
102
+			}
98 103
 			$str = substr_replace($str, '', $pos, $end-$pos+2);
99 104
 		}
100 105
 
@@ -107,7 +112,9 @@  discard block
 block discarded – undo
107 112
 		$return = [];
108 113
 
109 114
 		foreach ($rules as $rule) {
110
-			if (trim($rule) === '') continue;
115
+			if (trim($rule) === '') {
116
+				continue;
117
+			}
111 118
 			$parts = explode(':', $rule, 2);
112 119
 
113 120
 			$parts[1] = $stringExtractor->rebuild($parts[1]);
Please login to merge, or discard this patch.
src/Parser/Value.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 		$finalPos = $this->findMatchingPos($str, $marker);
65 65
 		$string = substr($str, 1, $finalPos-1);
66 66
 		//Now remove escape characters
67
-		return str_replace('\\' . $marker, $marker, $string);
67
+		return str_replace('\\'.$marker, $marker, $string);
68 68
 	}
69 69
 
70 70
 	private function parseFunction($function) {
Please login to merge, or discard this patch.
Braces   +33 added lines, -18 removed lines patch added patch discarded remove patch
@@ -33,8 +33,9 @@  discard block
 block discarded – undo
33 33
 			$params = $bracketMatcher->match('(', ')');
34 34
 			
35 35
 			return ['name' => $name, 'params' => $params, 'endPoint' => $bracketMatcher->getClosePos()];
36
+		} else {
37
+			return ['name' => null, 'params' => $function, 'endPoint' => strlen($function)];
36 38
 		}
37
-		else return ['name' => null, 'params' => $function, 'endPoint' => strlen($function)];
38 39
 	}
39 40
 
40 41
 	public function parse($function, \DomElement $element) {
@@ -55,13 +56,15 @@  discard block
 block discarded – undo
55 56
 		if ($function && in_array($function[0], ['\'', '"'])) {
56 57
 			$finalPos = $this->findMatchingPos($function, $function[0]);
57 58
 			$result[] = $this->extractQuotedString($function[0], $function);
58
-		}
59
-		else {
59
+		} else {
60 60
 			$func = $this->parseFunction($function);
61 61
 			$finalPos = $func['endPoint'];			
62 62
 
63
-			if (($data = $this->getFunctionValue($func['name'], $func['params'], $element)) !== self::IS_NOT_FUNCTION) $result = $this->appendToArray($result, $data);
64
-			else $result[] = trim($function);
63
+			if (($data = $this->getFunctionValue($func['name'], $func['params'], $element)) !== self::IS_NOT_FUNCTION) {
64
+				$result = $this->appendToArray($result, $data);
65
+			} else {
66
+				$result[] = trim($function);
67
+			}
65 68
 		}
66 69
 		$remaining = trim(substr($function, $finalPos+1));
67 70
 		return $this->parseNextValue($remaining, $result, $element);
@@ -70,23 +73,27 @@  discard block
 block discarded – undo
70 73
 	private function getFunctionValue($name, $params, $element) {
71 74
 		if (($data = $this->callFunc($name, $params, $element)) !== self::IS_NOT_FUNCTION) {
72 75
 			return $data;
73
-		}
74
-		else if ($this->parent != null && ($data = $this->parent->callFunc($name, $params, $element)) !== self::IS_NOT_FUNCTION) {
76
+		} else if ($this->parent != null && ($data = $this->parent->callFunc($name, $params, $element)) !== self::IS_NOT_FUNCTION) {
75 77
 			return $data;
78
+		} else {
79
+			return self::IS_NOT_FUNCTION;
76 80
 		}
77
-		else return self::IS_NOT_FUNCTION;
78 81
 	}
79 82
 
80 83
 	private function appendToArray($array, $value) {
81
-		if (is_array($value)) $array += $value;
82
-		else $array[] = $value;
84
+		if (is_array($value)) {
85
+			$array += $value;
86
+		} else {
87
+			$array[] = $value;
88
+		}
83 89
 		return $array;
84 90
 	}
85 91
 
86 92
 	private function callFunc($name, $params, $element) {
87 93
 		if ($name && $this->isCallable($this->dataFunction, $name)) {
88
-			if ($this->callParamsAsArray) return $this->dataFunction->$name($this->parse($params, $element), $element);	
89
-			else {
94
+			if ($this->callParamsAsArray) {
95
+				return $this->dataFunction->$name($this->parse($params, $element), $element);
96
+			} else {
90 97
 				return $this->callFuncOnObject($this->dataFunction, $name, $this->parse($params, $element));
91 98
 			}
92 99
 		}
@@ -103,18 +110,25 @@  discard block
 block discarded – undo
103 110
 		foreach ($params as $param) {
104 111
 			$stringExtractor = new StringExtractor($param);
105 112
 			$parts = explode(',', $stringExtractor);
106
-			foreach ($parts as $part) $args[] = $stringExtractor->rebuild($part);
113
+			foreach ($parts as $part) {
114
+				$args[] = $stringExtractor->rebuild($part);
115
+			}
107 116
 		}
108 117
 		return $this->callFuncOrClosure($obj, $func, $args);
109 118
 	}
110 119
 
111 120
 	private function callFuncOrClosure($obj, $func, $args) {
112
-		if (isset($obj->$func) && is_callable($obj->$func)) return call_user_func_array($obj->$func, $args);
113
-		else return call_user_func_array([$obj, $func], $args);
121
+		if (isset($obj->$func) && is_callable($obj->$func)) {
122
+			return call_user_func_array($obj->$func, $args);
123
+		} else {
124
+			return call_user_func_array([$obj, $func], $args);
125
+		}
114 126
 	}
115 127
 
116 128
 	private function parseNextValue($remaining, $result, $element) {
117
-		if (strlen($remaining) > 0 && $remaining[0] == ',') $result = array_merge($result, $this->parse(trim(substr($remaining, 1)), $element));
129
+		if (strlen($remaining) > 0 && $remaining[0] == ',') {
130
+			$result = array_merge($result, $this->parse(trim(substr($remaining, 1)), $element));
131
+		}
118 132
 		return $result;
119 133
 	}
120 134
 	
@@ -122,8 +136,9 @@  discard block
 block discarded – undo
122 136
 		$pos = $start+1;
123 137
 		$end = 0;
124 138
 		while ($end = strpos($string, $char, $pos)) {
125
-			if ($string[$end-1] === $escape) $pos = $end+1;
126
-			else {
139
+			if ($string[$end-1] === $escape) {
140
+				$pos = $end+1;
141
+			} else {
127 142
 				break;
128 143
 			}
129 144
 		}
Please login to merge, or discard this patch.
src/Parser/CssToXpath.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,8 +51,11 @@  discard block
 block discarded – undo
51 51
 	}
52 52
 
53 53
 	private static function compare($comparator, $a, $b) {
54
-		if ($comparator == '=') return $a == $b;
55
-		else if ($comparator == '!=') return $a != $b;
54
+		if ($comparator == '=') {
55
+			return $a == $b;
56
+		} else if ($comparator == '!=') {
57
+			return $a != $b;
58
+		}
56 59
 	}
57 60
 
58 61
 	//split the css into indivudal functions
@@ -66,8 +69,9 @@  discard block
 block discarded – undo
66 69
 				$selector = $this->createSelector();
67 70
 				$selector->type = $css[$i];
68 71
 				$selectors[] = $selector;
72
+			} else {
73
+				$selector->string .= $css[$i];
69 74
 			}
70
-			else $selector->string .= $css[$i];			
71 75
 		}
72 76
 		return $selectors;
73 77
 	}
@@ -78,7 +82,9 @@  discard block
 block discarded – undo
78 82
 		$this->depth = count($selectors);
79 83
 		$xpath = '/';
80 84
 		foreach ($selectors as $selector) {
81
-			if (isset($this->translators[$selector->type])) $xpath .= $this->translators[$selector->type]($selector->string, $xpath);
85
+			if (isset($this->translators[$selector->type])) {
86
+				$xpath .= $this->translators[$selector->type]($selector->string, $xpath);
87
+			}
82 88
 		}
83 89
 
84 90
 		$xpath = str_replace('/[', '/*[', $xpath);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@
 block discarded – undo
17 17
 	public function __construct($css, Value $valueParser, $prefix = '') {
18 18
 		$hash = $this->registerInstance();
19 19
 		$this->valueParser = $valueParser;
20
-		$this->css = str_replace([' >', '> '],['>', '>'], trim($css));
20
+		$this->css = str_replace([' >', '> '], ['>', '>'], trim($css));
21 21
 		$this->translators = [
22
-			' ' => function($string) use ($prefix) { return '//' . $prefix . $string;	},
23
-			'' => function($string) use ($prefix) { return '/' . $prefix . $string;	},
24
-			'>' => function($string) use ($prefix) { return '/' . $prefix  . $string; },
25
-			'#' => function($string) { return '[@id=\'' . $string . '\']'; },
26
-			'.' => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' ' . $string . ' \')]'; }, 
27
-			'[' => function($string) use ($hash) { return '[' .'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \'' . $string . '\', ., "' . $hash . '")' . ']';	},
22
+			' ' => function($string) use ($prefix) { return '//'.$prefix.$string; },
23
+			'' => function($string) use ($prefix) { return '/'.$prefix.$string; },
24
+			'>' => function($string) use ($prefix) { return '/'.$prefix.$string; },
25
+			'#' => function($string) { return '[@id=\''.$string.'\']'; },
26
+			'.' => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' '.$string.' \')]'; }, 
27
+			'[' => function($string) use ($hash) { return '['.'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \''.$string.'\', ., "'.$hash.'")'.']'; },
28 28
 			']' => function() {	return ''; }
29 29
 		];
30 30
 	}
Please login to merge, or discard this patch.