You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -263,19 +263,37 @@ Key Features:
263
263
### The `getString()` method
264
264
265
265
The `getString()` method retrieves the value of a specified field as a string from a data block. If the field does not exist or is null, it returns a default value, which can be customized.
266
+
266
267
Parameters:
267
268
268
269
-`$path` (string): The path to the field (e.g., "0.commit.author.date").
269
-
-`$default` (string): (Optional) The default value to return if the field doesn't exist. Defaults to an empty string ("").
270
+
-`$default` (string|null): (Optional) The default value to return if the field doesn't exist. Defaults to null.
270
271
271
272
Example Usage:
272
273
```php
273
274
$data1->getString("0.commit.author.date"); // Returns the field value as a string
$data1->getString("0.commit.comment_count"); // Returns "0" as a string even if the field value is an integer
277
278
```
278
279
280
+
### The `getStringStrict()` method
281
+
282
+
The `getStringStrict()` method retrieves the value of a specified field as a string from a data block. If the field does not exist or is null, it returns a default string value, which can be customized ("" by default).
283
+
284
+
Parameters:
285
+
286
+
-`$path` (string): The path to the field (e.g., "0.commit.author.date").
287
+
-`$default` (string): (Optional) The default value to return if the field doesn't exist. Defaults to "".
288
+
289
+
Example Usage:
290
+
```php
291
+
$data1->getStringStrict("0.commit.author.date"); // Returns the field value as a string
292
+
$data1->getStringStrict("0.commit.author.notexists"); // Returns an empty string ""
$data1->getStringStrict("0.commit.comment_count"); // Returns "0" as a string even if the field value is an integer
295
+
```
296
+
279
297
### The `getInt()` method
280
298
281
299
The `getInt()` method retrieves the value of a specified field as a integer from a data block. If the field does not exist or is null, it returns a default value, which can be customized (null by default).
0 commit comments