@@ -1,25 +1,25 @@ |
||
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 | - $path = $this->baseDir . $json; |
|
15 | - if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path); |
|
16 | - $json = file_get_contents($json); |
|
17 | - } |
|
13 | + if (trim($json)[0] != '{') { |
|
14 | + $path = $this->baseDir . $json; |
|
15 | + if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path); |
|
16 | + $json = file_get_contents($json); |
|
17 | + } |
|
18 | 18 | |
19 | - $map = json_decode($json, true); |
|
19 | + $map = json_decode($json, true); |
|
20 | 20 | |
21 | - if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg()); |
|
21 | + if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg()); |
|
22 | 22 | |
23 | - return $map; |
|
24 | - } |
|
23 | + return $map; |
|
24 | + } |
|
25 | 25 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | private $pseudo; |
11 | 11 | private $depth; |
12 | 12 | private $index; |
13 | - private $baseDir; |
|
13 | + private $baseDir; |
|
14 | 14 | private $properties = []; |
15 | 15 | private $lastRun = 0; |
16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $this->pseudo = $pseudo; |
26 | 26 | $this->depth = $depth; |
27 | 27 | $this->index = $index; |
28 | - $this->baseDir = $baseDir; |
|
28 | + $this->baseDir = $baseDir; |
|
29 | 29 | $this->properties = $properties; |
30 | 30 | } |
31 | 31 |
@@ -49,11 +49,11 @@ |
||
49 | 49 | $functionSet->setElement($element[0]); |
50 | 50 | |
51 | 51 | $attributes = array(); |
52 | - foreach($element[0]->attributes as $attribute_name => $attribute_node) { |
|
53 | - $attributes[$attribute_name] = $attribute_node->nodeValue; |
|
54 | - } |
|
52 | + foreach($element[0]->attributes as $attribute_name => $attribute_node) { |
|
53 | + $attributes[$attribute_name] = $attribute_node->nodeValue; |
|
54 | + } |
|
55 | 55 | |
56 | - $parser = new \Transphporm\Parser\Value($functionSet, true); |
|
56 | + $parser = new \Transphporm\Parser\Value($functionSet, true); |
|
57 | 57 | $return = $parser->parseTokens($attr, $attributes); |
58 | 58 | |
59 | 59 | return $return[0] === '' ? false : $return[0]; |