@@ -148,7 +148,9 @@ public function length($length)
148
148
throw new \InvalidArgumentException ('Param $length must be more than 0 ' );
149
149
}
150
150
151
- $ this ->string ();
151
+ if (!is_string ($ this ->value )) {
152
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'string ' ]);
153
+ }
152
154
153
155
if (mb_strlen ($ this ->value ) !== $ length ) {
154
156
throw $ this ->buildException (self ::EXCEPTION_LENGTH_TEXT_POSITIVE , ['{{value}} ' => $ length ]);
@@ -184,7 +186,9 @@ public function lengthBetween($from, $to)
184
186
throw new \InvalidArgumentException ('Param $from must be more than 0 ' );
185
187
}
186
188
187
- $ this ->string ();
189
+ if (!is_string ($ this ->value )) {
190
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'string ' ]);
191
+ }
188
192
189
193
$ length = mb_strlen ($ this ->value );
190
194
@@ -216,7 +220,9 @@ public function lengthLess($length)
216
220
throw new \InvalidArgumentException ('Param $length must be more than 0 ' );
217
221
}
218
222
219
- $ this ->string ();
223
+ if (!is_string ($ this ->value )) {
224
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'string ' ]);
225
+ }
220
226
221
227
if (mb_strlen ($ this ->value ) > $ length ) {
222
228
throw $ this ->buildException (self ::EXCEPTION_LENGTH_TEXT_POSITIVE , ['{{value}} ' => 'more than ' . $ length ]);
@@ -243,7 +249,9 @@ public function lengthMore($length)
243
249
throw new \InvalidArgumentException ('Param $length must be more than 0 ' );
244
250
}
245
251
246
- $ this ->notEmpty ()->string ();
252
+ if (!is_string ($ this ->value )) {
253
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'string ' ]);
254
+ }
247
255
248
256
if (mb_strlen ($ this ->value ) < $ length ) {
249
257
throw $ this ->buildException (self ::EXCEPTION_LENGTH_TEXT_POSITIVE , ['{{value}} ' => 'more than ' . $ length ]);
@@ -269,23 +277,6 @@ public function inArray(array $range)
269
277
return $ this ;
270
278
}
271
279
272
- /**
273
- * Check if value is not in array (in_array strict)
274
- *
275
- * @param array $range
276
- *
277
- * @return Variable
278
- * @throws \InvalidArgumentException
279
- */
280
- public function isNotInArray (array $ range )
281
- {
282
- if (in_array ($ this ->value , $ range , true )) {
283
- throw $ this ->buildException (self ::EXCEPTION_VALUE_IN_ARRAY_NEGATIVE , ['{{type}} ' => 'array ' ]);
284
- }
285
-
286
- return $ this ;
287
- }
288
-
289
280
/**
290
281
* Check if value is array
291
282
*
@@ -339,7 +330,9 @@ public function between($from, $to)
339
330
throw new \InvalidArgumentException ('Param $from must be less than $to ' );
340
331
}
341
332
342
- $ this ->numeric ()->notString ();
333
+ if (!is_int ($ this ->value ) && !is_float ($ this ->value )) {
334
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'int or float ' ]);
335
+ }
343
336
344
337
if ($ this ->value < $ from || $ this ->value > $ to ) {
345
338
throw $ this ->buildException (
@@ -374,7 +367,9 @@ public function betweenStrict($from, $to)
374
367
throw new \InvalidArgumentException ('Param $from must be less than $to ' );
375
368
}
376
369
377
- $ this ->numeric ()->notString ();
370
+ if (!is_int ($ this ->value ) && !is_float ($ this ->value )) {
371
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'int or float ' ]);
372
+ }
378
373
379
374
if ($ this ->value <= $ from || $ this ->value >= $ to ) {
380
375
throw $ this ->buildException (
@@ -424,7 +419,9 @@ public function notBool()
424
419
*/
425
420
public function digit ()
426
421
{
427
- $ this ->string ();
422
+ if (!is_string ($ this ->value )) {
423
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'string ' ]);
424
+ }
428
425
429
426
if (!ctype_digit ($ this ->value )) {
430
427
throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_NEGATIVE , ['{{type}} ' => 'digit ' ]);
@@ -538,7 +535,9 @@ public function less($number)
538
535
throw new \InvalidArgumentException ('Param $number must be int or float ' );
539
536
}
540
537
541
- $ this ->numeric ()->notString ();
538
+ if (!is_int ($ this ->value ) && !is_float ($ this ->value )) {
539
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'int or float ' ]);
540
+ }
542
541
543
542
if ($ this ->value > $ number ) {
544
543
throw $ this ->buildException (self ::EXCEPTION_VALUE_TEXT_POSITIVE , ['{{value}} ' => 'less than ' . $ number ]);
@@ -561,7 +560,9 @@ public function more($number)
561
560
throw new \InvalidArgumentException ('Param $number must be int or float ' );
562
561
}
563
562
564
- $ this ->numeric ()->notString ();
563
+ if (!is_int ($ this ->value ) && !is_float ($ this ->value )) {
564
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'int or float ' ]);
565
+ }
565
566
566
567
if ($ this ->value < $ number ) {
567
568
throw $ this ->buildException (self ::EXCEPTION_VALUE_TEXT_POSITIVE , ['{{value}} ' => 'more than ' . $ number ]);
@@ -584,7 +585,9 @@ public function lessStrict($number)
584
585
throw new \InvalidArgumentException ('Param $number must be int or float ' );
585
586
}
586
587
587
- $ this ->numeric ()->notString ();
588
+ if (!is_int ($ this ->value ) && !is_float ($ this ->value )) {
589
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'int or float ' ]);
590
+ }
588
591
589
592
if ($ this ->value >= $ number ) {
590
593
throw $ this ->buildException (self ::EXCEPTION_VALUE_TEXT_POSITIVE , ['{{value}} ' => 'less than ' . $ number ]);
@@ -607,7 +610,9 @@ public function moreStrict($number)
607
610
throw new \InvalidArgumentException ('Param $number must be int or float ' );
608
611
}
609
612
610
- $ this ->numeric ()->notString ();
613
+ if (!is_int ($ this ->value ) && !is_float ($ this ->value )) {
614
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'int or float ' ]);
615
+ }
611
616
612
617
if ($ this ->value <= $ number ) {
613
618
throw $ this ->buildException (self ::EXCEPTION_VALUE_TEXT_POSITIVE , ['{{value}} ' => 'more than ' . $ number ]);
@@ -681,7 +686,9 @@ public function glob($pattern)
681
686
*/
682
687
public function negative ()
683
688
{
684
- $ this ->numeric ()->notString ();
689
+ if (!is_int ($ this ->value ) && !is_float ($ this ->value )) {
690
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'int or float ' ]);
691
+ }
685
692
686
693
if ($ this ->value >= 0 ) {
687
694
throw $ this ->buildException (self ::EXCEPTION_VALUE_TEXT_POSITIVE , ['{{value}} ' => 'negative ' ]);
@@ -698,7 +705,9 @@ public function negative()
698
705
*/
699
706
public function positive ()
700
707
{
701
- $ this ->numeric ()->notString ();
708
+ if (!is_int ($ this ->value ) && !is_float ($ this ->value )) {
709
+ throw $ this ->buildException (self ::EXCEPTION_TYPE_TEXT_POSITIVE , ['{{type}} ' => 'int or float ' ]);
710
+ }
702
711
703
712
if ($ this ->value <= 0 ) {
704
713
throw $ this ->buildException (self ::EXCEPTION_VALUE_TEXT_POSITIVE , ['{{value}} ' => 'positive ' ]);
0 commit comments