Skip to content

Commit 617c106

Browse files
committed
refactor: upgrade to the new version
1 parent d235c23 commit 617c106

File tree

1 file changed

+36
-37
lines changed

1 file changed

+36
-37
lines changed

src/Json.php

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function exists(): bool
4949
*
5050
* @param bool $asObject If true and the value is an array, it is returned as an object.
5151
*
52-
* @throws GetFileException if the file could not be read.
52+
* @throws GetFileException if file reading failed.
5353
* @throws JsonErrorException if the file contains invalid JSON.
5454
*
5555
* @return mixed the contents of the JSON file.
@@ -71,15 +71,15 @@ public function get(bool $asObject = false): mixed
7171
* Set the contents of a JSON or a key within the file.
7272
*
7373
* @param mixed $content The data that will be written to the file or a key within the file.
74-
* @param string $dot The dot notation string representing the key to be modified within the file.
74+
* @param string $dot The dot notation representing the key to be modified within the file.
7575
*
76-
* @throws GetFileException if the file could not be read.
76+
* @throws GetFileException if file reading failed.
7777
* @throws JsonErrorException if the file contains invalid JSON.
78-
* @throws CreateDirectoryException if the file could not be created.
79-
* @throws CreateFileException if the directory could not be created.
80-
* @throws NoIterableElementException if the location specified by $dot is not an array.
78+
* @throws CreateFileException if file creation failed.
79+
* @throws CreateDirectoryException if directory creation failed.
80+
* @throws NoIterableElementException if $dot isn't an array location.
8181
*
82-
* @return mixed the content of the JSON file after the merge operation.
82+
* @return mixed the content of the JSON file after the set operation.
8383
*/
8484
public function set(mixed $content = [], string $dot = null): array|bool|int|null|string
8585
{
@@ -97,12 +97,12 @@ public function set(mixed $content = [], string $dot = null): array|bool|int|nul
9797
* Merge the provided data with the contents of a JSON file or a key within the file.
9898
*
9999
* @param mixed $content The data that will be written to the file or a key within the file.
100-
* @param string $dot The dot notation string representing the key to be modified within the file.
100+
* @param string $dot The dot notation representing the key to be modified within the file.
101101
*
102-
* @throws GetFileException if the file could not be read.
102+
* @throws GetFileException if file reading failed.
103103
* @throws JsonErrorException if the file contains invalid JSON.
104-
* @throws NoIterableFileException if the file does not contain an array.
105-
* @throws NoIterableElementException if the location specified by $dot is not an array.
104+
* @throws NoIterableFileException if the file isn't a JSON array.
105+
* @throws NoIterableElementException if $dot isn't an array location.
106106
*
107107
* @return mixed the content of the JSON file after the merge operation.
108108
*/
@@ -123,12 +123,12 @@ public function merge(array|object $content, string $dot = null): array
123123
/**
124124
* Remove and get the last element of a JSON file or a key within the file.
125125
*
126-
* @param string $dot The dot notation string representing the key to be modified within the file.
126+
* @param string $dot The dot notation representing the key to be modified within the file.
127127
*
128-
* @throws GetFileException if the file could not be read.
128+
* @throws GetFileException if file reading failed.
129129
* @throws JsonErrorException if the file contains invalid JSON.
130-
* @throws NoIterableFileException if the file does not contain an array.
131-
* @throws NoIterableElementException if the location specified by $dot is not an array.
130+
* @throws NoIterableFileException if the file isn't a JSON array.
131+
* @throws NoIterableElementException if $dot isn't an array location.
132132
*
133133
* @return mixed|null the last value of JSON file, or null if array is empty.
134134
*/
@@ -152,12 +152,12 @@ public function pop(string $dot = null): mixed
152152
* Add the provided data to the end of the contents of a JSON file or a key within the file.
153153
*
154154
* @param mixed $content The data that will be written to the file or a key within the file.
155-
* @param string $dot The dot notation string representing the key to be modified within the file.
155+
* @param string $dot The dot notation representing the key to be modified within the file.
156156
*
157-
* @throws GetFileException if the file could not be read.
157+
* @throws GetFileException if file reading failed.
158158
* @throws JsonErrorException if the file contains invalid JSON.
159-
* @throws NoIterableFileException if the file does not contain an array.
160-
* @throws NoIterableElementException if the location specified by $dot is not an array.
159+
* @throws NoIterableFileException if the file isn't a JSON array.
160+
* @throws NoIterableElementException if $dot isn't an array location.
161161
*
162162
* @return mixed the content of the JSON file after the push operation.
163163
*/
@@ -179,12 +179,12 @@ public function push(mixed $content, string $dot = null): array
179179
/**
180180
* Remove and get the first element of a JSON file or a key within the file.
181181
*
182-
* @param string $dot The dot notation string representing the key to be modified within the file.
182+
* @param string $dot The dot notation representing the key to be modified within the file.
183183
*
184-
* @throws GetFileException if the file could not be read.
184+
* @throws GetFileException if file reading failed.
185185
* @throws JsonErrorException if the file contains invalid JSON.
186-
* @throws NoIterableFileException if the file does not contain an array.
187-
* @throws NoIterableElementException if the location specified by $dot is not an array.
186+
* @throws NoIterableFileException if the file isn't a JSON array.
187+
* @throws NoIterableElementException if $dot isn't an array location.
188188
*
189189
* @return mixed|null the shifted value, or null if array is empty.
190190
*/
@@ -207,12 +207,12 @@ public function shift(string $dot = null): mixed
207207
/**
208208
* Remove a key and its value from the contents of a JSON file.
209209
*
210-
* @param string $dot The dot notation string representing the key to be modified within the file.
210+
* @param string $dot The dot notation representing the key to be modified within the file.
211211
* @param bool $reindexed If true, the array will be re-indexed.
212212
*
213-
* @throws GetFileException if the file could not be read.
213+
* @throws GetFileException if file reading failed.
214214
* @throws JsonErrorException if the file contains invalid JSON.
215-
* @throws NoIterableFileException if the file does not contain an array.
215+
* @throws NoIterableFileException if the file isn't a JSON array.
216216
*
217217
* @return array the content of the JSON file after the unset operation.
218218
*/
@@ -230,12 +230,12 @@ public function unset(string $dot, bool $reindexed = false): array
230230
* Add the provided data to the beginning of the contents of a JSON file or a key within the file.
231231
*
232232
* @param mixed $content The data that will be written to the file or a key within the file.
233-
* @param string $dot The dot notation string representing the key to be modified within the file.
233+
* @param string $dot The dot notation representing the key to be modified within the file.
234234
*
235-
* @throws GetFileException if the file could not be read.
235+
* @throws GetFileException if file reading failed.
236236
* @throws JsonErrorException if the file contains invalid JSON.
237-
* @throws NoIterableFileException if the file does not contain an array.
238-
* @throws NoIterableElementException if the location specified by $dot is not an array.
237+
* @throws NoIterableFileException if the file isn't a JSON array.
238+
* @throws NoIterableElementException if $dot isn't an array location.
239239
*
240240
* @return mixed the content of the JSON file after the unshift operation.
241241
*/
@@ -257,13 +257,12 @@ public function unshift(mixed $content, string $dot = null): mixed
257257
/**
258258
* Modify a nested array key by a dot notation string.
259259
*
260-
* @param string $type The type of modification to perform on the array.
261-
* This can be: merge|pop|push|set|unset.
260+
* @param string $type The type of operation to perform on the array.
262261
* @param mixed $array The array that will be modified.
263262
* @param mixed $dot The dot notation string representing the key of the nested array.
264263
* @param mixed $content The value that will be set or pushed to the array.
265264
*
266-
* @throws NoIterableElementException if the location specified by $dot is not an array.
265+
* @throws NoIterableElementException if $dot isn't an array location.
267266
*
268267
* @return mixed the contents that have been written to the file after the unshift operation.
269268
*/
@@ -311,8 +310,8 @@ protected function modifyArrayByDot(string $type, array &$array, string $dot, mi
311310
*
312311
* @param mixed $content The data to be encoded as JSON and saved to the file.
313312
*
314-
* @throws CreateFileException if the directory could not be created.
315-
* @throws CreateDirectoryException if the file could not be created.
313+
* @throws CreateFileException if directory creation failed.
314+
* @throws CreateDirectoryException if file creation failed.
316315
*
317316
* @return mixed the contents that have been saved to the file.
318317
*/
@@ -339,8 +338,8 @@ protected function saveToJsonFile(mixed $content): mixed
339338
* @param mixed $data The array to check.
340339
* @param string $param The dot notation or filepath.
341340
*
342-
* @throws NoIterableFileException if the file does not contain an array.
343-
* @throws NoIterableElementException if the location specified by $dot is not an array.
341+
* @throws NoIterableFileException if the file isn't a JSON array.
342+
* @throws NoIterableElementException if $dot isn't an array location.
344343
*/
345344
protected function failIfNotArray(string $type, mixed $data, string $param): void
346345
{

0 commit comments

Comments
 (0)