@@ -40,7 +40,7 @@ public function getInt(string $key, int $default = null): int
40
40
{
41
41
$ value = $ this ->find ($ key , $ default );
42
42
43
- if ($ value === null ) {
43
+ if ($ this -> isNullOrBlank ( $ value) ) {
44
44
throw new InvalidArgumentException (sprintf ('No value found for key "%s" ' , $ key ));
45
45
}
46
46
@@ -57,13 +57,13 @@ public function getInt(string $key, int $default = null): int
57
57
*/
58
58
public function findInt (string $ key , int $ default = null )
59
59
{
60
- $ result = $ this ->find ($ key , $ default );
60
+ $ value = $ this ->find ($ key , $ default );
61
61
62
- if ($ result === null ) {
62
+ if ($ this -> isNullOrBlank ( $ value ) ) {
63
63
return null ;
64
64
}
65
65
66
- return (int )$ result ;
66
+ return (int )$ value ;
67
67
}
68
68
69
69
/**
@@ -120,7 +120,7 @@ public function getArray(string $key, array $default = null): array
120
120
{
121
121
$ value = $ this ->find ($ key , $ default );
122
122
123
- if ($ value === null ) {
123
+ if ($ this -> isNullOrBlank ( $ value) ) {
124
124
throw new InvalidArgumentException (sprintf ('No value found for key "%s" ' , $ key ));
125
125
}
126
126
@@ -139,7 +139,7 @@ public function findArray(string $key, array $default = null)
139
139
{
140
140
$ value = $ this ->find ($ key , $ default );
141
141
142
- if ($ value === null ) {
142
+ if ($ this -> isNullOrBlank ( $ value) ) {
143
143
return null ;
144
144
}
145
145
@@ -160,7 +160,7 @@ public function getFloat(string $key, float $default = null): float
160
160
{
161
161
$ value = $ this ->find ($ key , $ default );
162
162
163
- if ($ value === null ) {
163
+ if ($ this -> isNullOrBlank ( $ value) ) {
164
164
throw new InvalidArgumentException (sprintf ('No value found for key "%s" ' , $ key ));
165
165
}
166
166
@@ -179,7 +179,7 @@ public function findFloat(string $key, float $default = null)
179
179
{
180
180
$ value = $ this ->find ($ key , $ default );
181
181
182
- if ($ value === null ) {
182
+ if ($ this -> isNullOrBlank ( $ value) ) {
183
183
return null ;
184
184
}
185
185
@@ -200,7 +200,7 @@ public function getBool(string $key, bool $default = null): bool
200
200
{
201
201
$ value = $ this ->find ($ key , $ default );
202
202
203
- if ($ value === null ) {
203
+ if ($ this -> isNullOrBlank ( $ value) ) {
204
204
throw new InvalidArgumentException (sprintf ('No value found for key "%s" ' , $ key ));
205
205
}
206
206
@@ -219,7 +219,7 @@ public function findBool(string $key, bool $default = null)
219
219
{
220
220
$ value = $ this ->find ($ key , $ default );
221
221
222
- if ($ value === null ) {
222
+ if ($ this -> isNullOrBlank ( $ value) ) {
223
223
return null ;
224
224
}
225
225
@@ -240,7 +240,7 @@ public function getChronos(string $key, Chronos $default = null): Chronos
240
240
{
241
241
$ value = $ this ->find ($ key , $ default );
242
242
243
- if ($ value === null ) {
243
+ if ($ this -> isNullOrBlank ( $ value) ) {
244
244
throw new InvalidArgumentException (sprintf ('No value found for key "%s" ' , $ key ));
245
245
}
246
246
@@ -265,7 +265,11 @@ public function findChronos(string $key, Chronos $default = null)
265
265
{
266
266
$ value = $ this ->find ($ key , $ default );
267
267
268
- if ($ value === null || $ value instanceof Chronos) {
268
+ if ($ this ->isNullOrBlank ($ value )) {
269
+ return null ;
270
+ }
271
+
272
+ if ($ value instanceof Chronos) {
269
273
return $ value ;
270
274
}
271
275
@@ -344,4 +348,16 @@ public function isEmpty(string $path): bool
344
348
{
345
349
return empty ($ this ->find ($ path ));
346
350
}
351
+
352
+ /**
353
+ * Is null or blank.
354
+ *
355
+ * @param mixed $value The value
356
+ *
357
+ * @return bool The status
358
+ */
359
+ private function isNullOrBlank ($ value ): bool
360
+ {
361
+ return $ value === null || $ value === '' ;
362
+ }
347
363
}
0 commit comments