Completed
Pull Request — master (#239)
by Nathan
04:30
created
src/Parser/ValueData.php 1 patch
Braces   +26 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,14 +20,18 @@  discard block
 block discarded – undo
20 20
 	//Read $key from array, $this->data = $this->data[$key] but also works for objects
21 21
 	private function traverseInto($key)
22 22
 	{
23
-		if (isset($this->data->{$key})) $this->data = $this->data->{$key};
24
-		else if ($this->isArray() && isset($this->data[$key])) $this->data = $this->data[$key];
23
+		if (isset($this->data->{$key})) {
24
+			$this->data = $this->data->{$key};
25
+		} else if ($this->isArray() && isset($this->data[$key])) {
26
+			$this->data = $this->data[$key];
27
+		}
25 28
 	}
26 29
 
27 30
 	public function traverse($key, $result)
28 31
 	{
29
-		if ($key !== null) $this->traverseInto($key);
30
-		else {
32
+		if ($key !== null) {
33
+			$this->traverseInto($key);
34
+		} else {
31 35
 			//But if the key is null, replace the data structure with the result of the last function call
32 36
 			$lastResult = $result->pop();
33 37
 			if ($lastResult) {
@@ -50,9 +54,14 @@  discard block
 block discarded – undo
50 54
 	public function read($value)
51 55
 	{
52 56
 		if ($this->isArray()) {
53
-			if (isset($this->data[$value])) return $this->data[$value];
54
-		} else if (isset($this->data->$value)) return $this->data->$value;
55
-		else return null;
57
+			if (isset($this->data[$value])) {
58
+				return $this->data[$value];
59
+			}
60
+		} else if (isset($this->data->$value)) {
61
+			return $this->data->$value;
62
+		} else {
63
+			return null;
64
+		}
56 65
 	}
57 66
 
58 67
 	public function call($func, $args)
@@ -73,15 +82,21 @@  discard block
 block discarded – undo
73 82
 	public function parseNested($parser, $token, $funcName)
74 83
 	{
75 84
 		$args = $parser->parseTokens($token['value'], $this->data);
76
-		if ($args[0] === $this->data) $args = [];
85
+		if ($args[0] === $this->data) {
86
+			$args = [];
87
+		}
77 88
 		return $this->callFuncOnObject($this->data, $funcName, $args);
78 89
 	}
79 90
 
80 91
 	private function callFuncOnObject($obj, $func, $args)
81 92
 	{
82
-		if (isset($obj->$func) && is_callable($obj->$func)) return call_user_func_array($obj->$func, $args);
83
-		else if (is_callable([$obj, $func])) return call_user_func_array([$obj, $func], $args);
84
-		else return false;
93
+		if (isset($obj->$func) && is_callable($obj->$func)) {
94
+			return call_user_func_array($obj->$func, $args);
95
+		} else if (is_callable([$obj, $func])) {
96
+			return call_user_func_array([$obj, $func], $args);
97
+		} else {
98
+			return false;
99
+		}
85 100
 	}
86 101
 
87 102
 	public function extract($last, $autoLookup, $traversing)
Please login to merge, or discard this patch.