Skip to content

Commit 4d41e9b

Browse files
author
Andrey Helldar
authored
Fixed error saving JSON file
1 parent 60bd5f0 commit 4d41e9b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Services/File.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ public function loadJson(string $filename)
4444
return json_decode(file_get_contents($filename), true);
4545
}
4646

47-
public function store(string $path)
47+
public function store(string $path): void
4848
{
4949
if ($this->isJson($path)) {
50-
FileSupport::store(
51-
$path,
52-
json_encode($this->content, JSON_PRETTY_PRINT)
53-
);
50+
$this->storeAsJson($path);
51+
52+
return;
5453
}
5554

5655
$content = Stub::replace(Stub::CONFIG_FILE, [
@@ -60,6 +59,14 @@ public function store(string $path)
6059
FileSupport::store($path, $content);
6160
}
6261

62+
public function storeAsJson(string $path): void
63+
{
64+
FileSupport::store(
65+
$path,
66+
json_encode($this->content, JSON_PRETTY_PRINT)
67+
);
68+
}
69+
6370
public function isJson(string $filename): bool
6471
{
6572
$extension = pathinfo($filename, PATHINFO_EXTENSION);

0 commit comments

Comments
 (0)