Skip to content

Commit 7d82979

Browse files
committed
docs: improve doc comments
Closes #20
1 parent f38b79b commit 7d82979

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/Json.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
namespace Josantonius\Json;
1515

16-
use Josantonius\Json\Exception\GetFileException;
17-
use Josantonius\Json\Exception\JsonErrorException;
18-
use Josantonius\Json\Exception\CreateFileException;
19-
use Josantonius\Json\Exception\CreateDirectoryException;
20-
use Josantonius\Json\Exception\UnavailableMethodException;
16+
use Josantonius\Json\Exceptions\GetFileException;
17+
use Josantonius\Json\Exceptions\JsonErrorException;
18+
use Josantonius\Json\Exceptions\CreateFileException;
19+
use Josantonius\Json\Exceptions\CreateDirectoryException;
20+
use Josantonius\Json\Exceptions\UnavailableMethodException;
2121

2222
/**
2323
* PHP simple library for managing JSON files.
@@ -30,9 +30,9 @@ class Json
3030
private bool $isUrl;
3131

3232
/**
33-
* @throws CreateDirectoryException
34-
* @throws CreateFileException
35-
* @throws JsonErrorException
33+
* @throws CreateDirectoryException if the directory cannot be created.
34+
* @throws CreateFileException if the file cannot be created.
35+
* @throws JsonErrorException if the JSON has errors.
3636
*/
3737
public function __construct(private string $filepath)
3838
{
@@ -46,8 +46,8 @@ public function __construct(private string $filepath)
4646
/**
4747
* Get the content of the JSON file or a remote JSON file.
4848
*
49-
* @throws GetFileException
50-
* @throws JsonErrorException
49+
* @throws GetFileException if the file cannot be read.
50+
* @throws JsonErrorException if the JSON has errors.
5151
*/
5252
public function get(): array
5353
{
@@ -57,9 +57,9 @@ public function get(): array
5757
/**
5858
* Set the content of the JSON file.
5959
*
60-
* @throws CreateFileException
61-
* @throws JsonErrorException
62-
* @throws UnavailableMethodException
60+
* @throws CreateFileException if the file cannot be created.
61+
* @throws JsonErrorException if the JSON has errors.
62+
* @throws UnavailableMethodException if an unavailable method is accessed.
6363
*/
6464
public function set(array|object $content): void
6565
{
@@ -69,10 +69,10 @@ public function set(array|object $content): void
6969
/**
7070
* Merge into JSON file.
7171
*
72-
* @throws CreateFileException
73-
* @throws GetFileException
74-
* @throws JsonErrorException
75-
* @throws UnavailableMethodException
72+
* @throws CreateFileException if the file cannot be created.
73+
* @throws GetFileException if the file cannot be read.
74+
* @throws JsonErrorException if the JSON has errors.
75+
* @throws UnavailableMethodException if an unavailable method is accessed.
7676
*/
7777
public function merge(array|object $content): array
7878
{
@@ -86,10 +86,10 @@ public function merge(array|object $content): array
8686
/**
8787
* Push on the JSON file.
8888
*
89-
* @throws CreateFileException
90-
* @throws GetFileException
91-
* @throws JsonErrorException
92-
* @throws UnavailableMethodException
89+
* @throws CreateFileException if the file cannot be created.
90+
* @throws GetFileException if the file cannot be read.
91+
* @throws JsonErrorException if the JSON has errors.
92+
* @throws UnavailableMethodException if an unavailable method is accessed.
9393
*/
9494
public function push(array|object $content): array
9595
{
@@ -105,9 +105,9 @@ public function push(array|object $content): array
105105
/**
106106
* Create file if not exists.
107107
*
108-
* @throws CreateDirectoryException
109-
* @throws CreateFileException
110-
* @throws JsonErrorException
108+
* @throws CreateDirectoryException if the directory cannot be created.
109+
* @throws CreateFileException if the file cannot be created.
110+
* @throws JsonErrorException if the JSON has errors.
111111
*/
112112
private function createFileIfNotExists(): void
113113
{
@@ -120,7 +120,7 @@ private function createFileIfNotExists(): void
120120
/**
121121
* Create directory if not exists.
122122
*
123-
* @throws CreateDirectoryException
123+
* @throws CreateDirectoryException if the directory cannot be created.
124124
*/
125125
private function createDirIfNotExists(): void
126126
{
@@ -134,8 +134,8 @@ private function createDirIfNotExists(): void
134134
/**
135135
* Get the content of the JSON file or a remote JSON file.
136136
*
137-
* @throws GetFileException
138-
* @throws JsonErrorException
137+
* @throws GetFileException if the file cannot be read.
138+
* @throws JsonErrorException if the JSON has errors.
139139
*/
140140
private function getFileContents(): array
141141
{
@@ -155,8 +155,8 @@ private function getFileContents(): array
155155
/**
156156
* Save content in JSON file.
157157
*
158-
* @throws CreateFileException
159-
* @throws JsonErrorException
158+
* @throws CreateFileException if the file cannot be created.
159+
* @throws JsonErrorException if the JSON has errors.
160160
*/
161161
private function saveToJsonFile(array|object $array): void
162162
{
@@ -172,7 +172,7 @@ private function saveToJsonFile(array|object $array): void
172172
/**
173173
* Check for JSON errors.
174174
*
175-
* @throws JsonErrorException
175+
* @throws JsonErrorException if the JSON has errors.
176176
*/
177177
private function checkJsonLastError(): void
178178
{
@@ -184,7 +184,7 @@ private function checkJsonLastError(): void
184184
/**
185185
* Throw exception if the method is not available for remote JSON files.
186186
*
187-
* @throws UnavailableMethodException
187+
* @throws UnavailableMethodException if an unavailable method is accessed.
188188
*/
189189
private function throwUnavailableMethodException(): void
190190
{

0 commit comments

Comments
 (0)