@@ -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,10 +37,16 @@ |
||
| 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 ($name == 'true') $tokens->add(['type' => Tokenizer::BOOL, 'value' => true]); |
|
| 42 | - else if ($name == 'false') $tokens->add(['type' => Tokenizer::BOOL, 'value' => false]); |
|
| 43 | - else if ($name == 'in') $tokens->add(['type' => Tokenizer::IN, 'value' => 'in']); |
|
| 44 | - 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 ($name == 'true') { |
|
| 43 | + $tokens->add(['type' => Tokenizer::BOOL, 'value' => true]); |
|
| 44 | + } else if ($name == 'false') { |
|
| 45 | + $tokens->add(['type' => Tokenizer::BOOL, 'value' => false]); |
|
| 46 | + } else if ($name == 'in') { |
|
| 47 | + $tokens->add(['type' => Tokenizer::IN, 'value' => 'in']); |
|
| 48 | + } else { |
|
| 49 | + $tokens->add(['type' => Tokenizer::NAME, 'value' => $name, 'line' => $str->lineNo()]); |
|
| 50 | + } |
|
| 45 | 51 | } |
| 46 | 52 | } |
| 47 | 53 | \ No newline at end of file |
@@ -33,14 +33,17 @@ |
||
| 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 | |