Skip to content

Commit c44e732

Browse files
committed
feat: add new methods
Exists and getFilepath methods were added. The file is no longer created if it does not exist when the instance is created. The $content parameter of the set method is now optional and contains an empty array by default. Closes #22
1 parent 5f46cd0 commit c44e732

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Json.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ public function exists(): bool
4343
return $this->isUrl ? @file_get_contents($filepath) !== false : file_exists($filepath);
4444
}
4545

46+
/**
47+
* Get the path or URL of the JSON file.
48+
*/
49+
public function filepath(): string
50+
{
51+
return $this->filepath;
52+
}
53+
4654
/**
4755
* Get the content of the JSON file or a remote JSON file.
4856
*
@@ -54,14 +62,6 @@ public function get(): array
5462
return $this->getFileContents();
5563
}
5664

57-
/**
58-
* Get the path or URL of the JSON file.
59-
*/
60-
public function getFilepath(): string
61-
{
62-
return $this->filepath;
63-
}
64-
6565
/**
6666
* Set the content of the JSON file.
6767
*

0 commit comments

Comments
 (0)