|
4 | 4 |
|
5 | 5 | use Helldar\PrettyArray\Exceptions\FileDoesntExistsException;
|
6 | 6 | use Helldar\Support\Facades\File as FileSupport;
|
7 |
| -use Helldar\Support\Facades\Str; |
8 | 7 | use Helldar\Support\Tools\Stub;
|
9 | 8 |
|
10 | 9 | class File
|
@@ -34,43 +33,25 @@ public function load(string $filename)
|
34 | 33 | throw new FileDoesntExistsException($filename);
|
35 | 34 | }
|
36 | 35 |
|
37 |
| - return $this->isJson($filename) |
38 |
| - ? $this->loadJson($filename) |
39 |
| - : require $filename; |
| 36 | + return require $filename; |
40 | 37 | }
|
41 | 38 |
|
42 |
| - public function loadJson(string $filename) |
| 39 | + public function loadRaw(string $filename) |
43 | 40 | {
|
44 |
| - return json_decode(file_get_contents($filename), true); |
| 41 | + return file_get_contents($filename); |
45 | 42 | }
|
46 | 43 |
|
47 | 44 | public function store(string $path): void
|
48 | 45 | {
|
49 |
| - if ($this->isJson($path)) { |
50 |
| - $this->storeAsJson($path); |
51 |
| - |
52 |
| - return; |
53 |
| - } |
54 |
| - |
55 | 46 | $content = Stub::replace(Stub::CONFIG_FILE, [
|
56 | 47 | '{{slot}}' => $this->content,
|
57 | 48 | ]);
|
58 | 49 |
|
59 | 50 | FileSupport::store($path, $content);
|
60 | 51 | }
|
61 | 52 |
|
62 |
| - public function storeAsJson(string $path): void |
| 53 | + public function storeRaw(string $path): void |
63 | 54 | {
|
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); |
75 | 56 | }
|
76 | 57 | }
|
0 commit comments