From 55b11d84e78bc1f4ba14506a33bf84f334be708d Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Fri, 10 Jul 2020 19:24:57 +0300 Subject: [PATCH] Loading and saving JSON replaced by RAW --- src/Services/File.php | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/Services/File.php b/src/Services/File.php index 3483a23..4ae1f66 100644 --- a/src/Services/File.php +++ b/src/Services/File.php @@ -4,7 +4,6 @@ use Helldar\PrettyArray\Exceptions\FileDoesntExistsException; use Helldar\Support\Facades\File as FileSupport; -use Helldar\Support\Facades\Str; use Helldar\Support\Tools\Stub; class File @@ -34,24 +33,16 @@ public function load(string $filename) throw new FileDoesntExistsException($filename); } - return $this->isJson($filename) - ? $this->loadJson($filename) - : require $filename; + return require $filename; } - public function loadJson(string $filename) + public function loadRaw(string $filename) { - return json_decode(file_get_contents($filename), true); + return file_get_contents($filename); } public function store(string $path): void { - if ($this->isJson($path)) { - $this->storeAsJson($path); - - return; - } - $content = Stub::replace(Stub::CONFIG_FILE, [ '{{slot}}' => $this->content, ]); @@ -59,18 +50,8 @@ public function store(string $path): void FileSupport::store($path, $content); } - public function storeAsJson(string $path): void + public function storeRaw(string $path): void { - FileSupport::store( - $path, - json_encode($this->content, JSON_PRETTY_PRINT) - ); - } - - public function isJson(string $filename): bool - { - $extension = pathinfo($filename, PATHINFO_EXTENSION); - - return Str::lower($extension) === 'json'; + FileSupport::store($path, $this->content); } }