Conditions | 5 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
27 | public function performAction() |
||
28 | { |
||
29 | $fileData = file_get_contents($this->path); |
||
30 | if (!$fileData) { |
||
31 | $this->response->error('Unable to read ' . $this->path); |
||
32 | return; |
||
33 | } |
||
34 | if (substr($this->path, -5) === '.yaml' || substr($this->path, -4) === '.yml') { |
||
35 | $jsonData = Yaml::parse($fileData, Yaml::PARSE_OBJECT); |
||
36 | } else { |
||
37 | $jsonData = json_decode($fileData); |
||
38 | } |
||
39 | |||
40 | $result = json_encode($jsonData, JSON_UNESCAPED_SLASHES); |
||
41 | |||
42 | if ($this->output) { |
||
43 | file_put_contents($this->output, $result); |
||
44 | } else { |
||
45 | $this->response->addContent($result); |
||
46 | } |
||
49 | } |