@@ -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 | } |
@@ -1,25 +1,25 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Transphporm\Formatter; |
3 | 3 | class Nl2br { |
4 | - public function nl2br($var) { |
|
5 | - $parts = explode("\n", $var); |
|
6 | - $doc = new \DomDocument(); |
|
7 | - $root = $doc->createElement('root'); |
|
8 | - $doc->appendChild($root); |
|
4 | + public function nl2br($var) { |
|
5 | + $parts = explode("\n", $var); |
|
6 | + $doc = new \DomDocument(); |
|
7 | + $root = $doc->createElement('root'); |
|
8 | + $doc->appendChild($root); |
|
9 | 9 | |
10 | - foreach ($parts as $key => $part) { |
|
11 | - $new = $doc->createTextNode($part); |
|
12 | - $doc->documentElement->appendChild($new); |
|
13 | - if ($key !== count($parts)-1) { |
|
14 | - $br = $doc->createElement('br'); |
|
15 | - $doc->documentElement->appendChild($br); |
|
16 | - } |
|
17 | - } |
|
10 | + foreach ($parts as $key => $part) { |
|
11 | + $new = $doc->createTextNode($part); |
|
12 | + $doc->documentElement->appendChild($new); |
|
13 | + if ($key !== count($parts)-1) { |
|
14 | + $br = $doc->createElement('br'); |
|
15 | + $doc->documentElement->appendChild($br); |
|
16 | + } |
|
17 | + } |
|
18 | 18 | |
19 | - return $this->getContent($doc); |
|
20 | - } |
|
19 | + return $this->getContent($doc); |
|
20 | + } |
|
21 | 21 | |
22 | - private function getContent($document) { |
|
22 | + private function getContent($document) { |
|
23 | 23 | $newNode = $document->documentElement; |
24 | 24 | $result = []; |
25 | 25 | if ($newNode->tagName === 'root') { |