public function prettify()
{
$parser = new JsonParser();
foreach ($this->files as $file) {
$raw = $this->fs->get($file);
$data = $parser->parse($raw);
$pretty = json_encode($data, JSON_PRETTY_PRINT);
$tmp_name = $file . '.tmp';
if ($this->fs->put($tmp_name, $pretty) === false) {
throw new \Exception('Couldn\'t write to ' . $tmp_name);
}
if (!$this->fs->delete($file)) {
throw new \Exception('Couldn\'t delete ' . $file);
}
if (!$this->fs->move($tmp_name, $file)) {
throw new \Exception('Couldn\'t rename ' . $tmp_name);
}
}
}