@@ -17,13 +17,13 @@ |
||
17 | 17 | |
18 | 18 | if ($this->isJsonFile($json)) { |
19 | 19 | $path = $this->filePath->getFilePath($json); |
20 | - if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path); |
|
20 | + if (!file_exists($path)) throw new \Exception('File does not exist at: '.$path); |
|
21 | 21 | $json = file_get_contents($path); |
22 | 22 | } |
23 | 23 | |
24 | 24 | $map = json_decode($json, true); |
25 | 25 | |
26 | - if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg()); |
|
26 | + if (!is_array($map)) throw new \Exception('Could not decode json: '.json_last_error_msg()); |
|
27 | 27 | |
28 | 28 | return $map; |
29 | 29 | } |
@@ -17,13 +17,17 @@ |
||
17 | 17 | |
18 | 18 | if ($this->isJsonFile($json)) { |
19 | 19 | $path = $this->filePath->getFilePath($json); |
20 | - if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path); |
|
20 | + if (!file_exists($path)) { |
|
21 | + throw new \Exception('File does not exist at: ' . $path); |
|
22 | + } |
|
21 | 23 | $json = file_get_contents($path); |
22 | 24 | } |
23 | 25 | |
24 | 26 | $map = json_decode($json, true); |
25 | 27 | |
26 | - if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg()); |
|
28 | + if (!is_array($map)) { |
|
29 | + throw new \Exception('Could not decode json: ' . json_last_error_msg()); |
|
30 | + } |
|
27 | 31 | |
28 | 32 | return $map; |
29 | 33 | } |
@@ -25,7 +25,9 @@ |
||
25 | 25 | /** 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*/ |
26 | 26 | public function getData(\DomElement $element = null, $type = 'data') { |
27 | 27 | while ($element) { |
28 | - if (isset($this->elementMap[$element]) && array_key_exists($type, $this->elementMap[$element])) return $this->elementMap[$element][$type]; |
|
28 | + if (isset($this->elementMap[$element]) && array_key_exists($type, $this->elementMap[$element])) { |
|
29 | + return $this->elementMap[$element][$type]; |
|
30 | + } |
|
29 | 31 | $element = $element->parentNode; |
30 | 32 | } |
31 | 33 | return $this->data; |
@@ -37,9 +37,13 @@ |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | private function processLiterals($tokens, $name, $str) { |
40 | - if (is_numeric($name)) $tokens->add(['type' => Tokenizer::NUMERIC, 'value' => $name]); |
|
41 | - else if (method_exists($this, $name)) $this->$name($tokens); |
|
42 | - else $tokens->add(['type' => Tokenizer::NAME, 'value' => $name, 'line' => $str->lineNo()]); |
|
40 | + if (is_numeric($name)) { |
|
41 | + $tokens->add(['type' => Tokenizer::NUMERIC, 'value' => $name]); |
|
42 | + } else if (method_exists($this, $name)) { |
|
43 | + $this->$name($tokens); |
|
44 | + } else { |
|
45 | + $tokens->add(['type' => Tokenizer::NAME, 'value' => $name, 'line' => $str->lineNo()]); |
|
46 | + } |
|
43 | 47 | } |
44 | 48 | |
45 | 49 | private function true($tokens) { |
@@ -108,7 +108,7 @@ |
||
108 | 108 | |
109 | 109 | //Postprocessing - replace values with null where allowed, or override a value at position |
110 | 110 | public function postProcess(ValueData $data, $val, $overrideVal, $allowNull) { |
111 | - if ($this->getMode() !== Tokenizer::ARG) return; |
|
111 | + if ($this->getMode() !== Tokenizer::ARG) return; |
|
112 | 112 | foreach ($this->getResult() as $i => $value) { |
113 | 113 | if (is_scalar($value)) { |
114 | 114 | $val = ($overrideVal == $val) ? $data->read($value) : $overrideVal; |
@@ -33,14 +33,17 @@ discard block |
||
33 | 33 | ]; |
34 | 34 | |
35 | 35 | if ($funcs[$this->mode] === 'concat' && is_numeric($newValue) |
36 | - && is_numeric($this->result[count($this->result)-1])) |
|
37 | - $this->add($newValue); |
|
38 | - else |
|
39 | - $this->{$funcs[$this->mode]}($newValue); |
|
36 | + && is_numeric($this->result[count($this->result)-1])) { |
|
37 | + $this->add($newValue); |
|
38 | + } else { |
|
39 | + $this->{$funcs[$this->mode]}($newValue); |
|
40 | + } |
|
40 | 41 | } |
41 | 42 | |
42 | 43 | public function in($value) { |
43 | - if (!is_array($value)) throw new \Exception(' `in` can only be used with arrays'); |
|
44 | + if (!is_array($value)) { |
|
45 | + throw new \Exception(' `in` can only be used with arrays'); |
|
46 | + } |
|
44 | 47 | $this->result[count($this->result)-1] = in_array($this->result[count($this->result)-1], $value); |
45 | 48 | } |
46 | 49 | |
@@ -108,7 +111,9 @@ discard block |
||
108 | 111 | |
109 | 112 | //Postprocessing - replace values with null where allowed, or override a value at position |
110 | 113 | public function postProcess(ValueData $data, $val, $overrideVal, $allowNull) { |
111 | - if ($this->getMode() !== Tokenizer::ARG) return; |
|
114 | + if ($this->getMode() !== Tokenizer::ARG) { |
|
115 | + return; |
|
116 | + } |
|
112 | 117 | foreach ($this->getResult() as $i => $value) { |
113 | 118 | if (is_scalar($value)) { |
114 | 119 | $val = ($overrideVal == $val) ? $data->read($value) : $overrideVal; |