@@ -1,27 +1,27 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Transphporm\TSSFunction; |
3 | 3 | class Json implements \Transphporm\TSSFunction { |
4 | - private $baseDir; |
|
4 | + private $baseDir; |
|
5 | 5 | |
6 | - public function __construct(&$baseDir) { |
|
7 | - $this->baseDir = &$baseDir; |
|
8 | - } |
|
6 | + public function __construct(&$baseDir) { |
|
7 | + $this->baseDir = &$baseDir; |
|
8 | + } |
|
9 | 9 | |
10 | - public function run(array $args, \DomElement $element = null) { |
|
11 | - $json = $args[0]; |
|
10 | + public function run(array $args, \DomElement $element = null) { |
|
11 | + $json = $args[0]; |
|
12 | 12 | |
13 | - if (trim($json)[0] != '{') { |
|
14 | - if (is_file($this->baseDir . $args[0])) $jsonFile = $this->baseDir . $json; |
|
15 | - elseif (is_file($args[0])) $jsonFile = $json; |
|
16 | - else throw new \Exception('JSON File "' . $json .'" does not exist'); |
|
13 | + if (trim($json)[0] != '{') { |
|
14 | + if (is_file($this->baseDir . $args[0])) $jsonFile = $this->baseDir . $json; |
|
15 | + elseif (is_file($args[0])) $jsonFile = $json; |
|
16 | + else throw new \Exception('JSON File "' . $json .'" does not exist'); |
|
17 | 17 | |
18 | - $json = file_get_contents($jsonFile); |
|
19 | - } |
|
18 | + $json = file_get_contents($jsonFile); |
|
19 | + } |
|
20 | 20 | |
21 | - $map = json_decode($json, true); |
|
21 | + $map = json_decode($json, true); |
|
22 | 22 | |
23 | - if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg()); |
|
23 | + if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg()); |
|
24 | 24 | |
25 | - return $map; |
|
26 | - } |
|
25 | + return $map; |
|
26 | + } |
|
27 | 27 | } |