Skip to content

Commit 55b11d8

Browse files
author
Andrey Helldar
authored
Loading and saving JSON replaced by RAW
1 parent 4d41e9b commit 55b11d8

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

src/Services/File.php

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Helldar\PrettyArray\Exceptions\FileDoesntExistsException;
66
use Helldar\Support\Facades\File as FileSupport;
7-
use Helldar\Support\Facades\Str;
87
use Helldar\Support\Tools\Stub;
98

109
class File
@@ -34,43 +33,25 @@ public function load(string $filename)
3433
throw new FileDoesntExistsException($filename);
3534
}
3635

37-
return $this->isJson($filename)
38-
? $this->loadJson($filename)
39-
: require $filename;
36+
return require $filename;
4037
}
4138

42-
public function loadJson(string $filename)
39+
public function loadRaw(string $filename)
4340
{
44-
return json_decode(file_get_contents($filename), true);
41+
return file_get_contents($filename);
4542
}
4643

4744
public function store(string $path): void
4845
{
49-
if ($this->isJson($path)) {
50-
$this->storeAsJson($path);
51-
52-
return;
53-
}
54-
5546
$content = Stub::replace(Stub::CONFIG_FILE, [
5647
'{{slot}}' => $this->content,
5748
]);
5849

5950
FileSupport::store($path, $content);
6051
}
6152

62-
public function storeAsJson(string $path): void
53+
public function storeRaw(string $path): void
6354
{
64-
FileSupport::store(
65-
$path,
66-
json_encode($this->content, JSON_PRETTY_PRINT)
67-
);
68-
}
69-
70-
public function isJson(string $filename): bool
71-
{
72-
$extension = pathinfo($filename, PATHINFO_EXTENSION);
73-
74-
return Str::lower($extension) === 'json';
55+
FileSupport::store($path, $this->content);
7556
}
7657
}

0 commit comments

Comments
 (0)