Code Duplication    Length = 9-10 lines in 16 locations

src/Assert.php 16 locations

@@ 329-337 (lines=9) @@
326
        }
327
    }
328
329
    public static function null($value, $message = '')
330
    {
331
        if (null !== $value) {
332
            static::reportInvalidArgument(sprintf(
333
                $message ?: 'Expected null. Got: %s',
334
                static::valueToString($value)
335
            ));
336
        }
337
    }
338
339
    public static function notNull($value, $message = '')
340
    {
@@ 348-356 (lines=9) @@
345
        }
346
    }
347
348
    public static function true($value, $message = '')
349
    {
350
        if (true !== $value) {
351
            static::reportInvalidArgument(sprintf(
352
                $message ?: 'Expected a value to be true. Got: %s',
353
                static::valueToString($value)
354
            ));
355
        }
356
    }
357
358
    public static function false($value, $message = '')
359
    {
@@ 358-366 (lines=9) @@
355
        }
356
    }
357
358
    public static function false($value, $message = '')
359
    {
360
        if (false !== $value) {
361
            static::reportInvalidArgument(sprintf(
362
                $message ?: 'Expected a value to be false. Got: %s',
363
                static::valueToString($value)
364
            ));
365
        }
366
    }
367
368
    public static function eq($value, $value2, $message = '')
369
    {
@@ 368-377 (lines=10) @@
365
        }
366
    }
367
368
    public static function eq($value, $value2, $message = '')
369
    {
370
        if ($value2 != $value) {
371
            static::reportInvalidArgument(sprintf(
372
                $message ?: 'Expected a value equal to %2$s. Got: %s',
373
                static::valueToString($value),
374
                static::valueToString($value2)
375
            ));
376
        }
377
    }
378
379
    public static function notEq($value, $value2, $message = '')
380
    {
@@ 389-398 (lines=10) @@
386
        }
387
    }
388
389
    public static function same($value, $value2, $message = '')
390
    {
391
        if ($value2 !== $value) {
392
            static::reportInvalidArgument(sprintf(
393
                $message ?: 'Expected a value identical to %2$s. Got: %s',
394
                static::valueToString($value),
395
                static::valueToString($value2)
396
            ));
397
        }
398
    }
399
400
    public static function notSame($value, $value2, $message = '')
401
    {
@@ 410-419 (lines=10) @@
407
        }
408
    }
409
410
    public static function greaterThan($value, $limit, $message = '')
411
    {
412
        if ($value <= $limit) {
413
            static::reportInvalidArgument(sprintf(
414
                $message ?: 'Expected a value greater than %2$s. Got: %s',
415
                static::valueToString($value),
416
                static::valueToString($limit)
417
            ));
418
        }
419
    }
420
421
    public static function greaterThanEq($value, $limit, $message = '')
422
    {
@@ 421-430 (lines=10) @@
418
        }
419
    }
420
421
    public static function greaterThanEq($value, $limit, $message = '')
422
    {
423
        if ($value < $limit) {
424
            static::reportInvalidArgument(sprintf(
425
                $message ?: 'Expected a value greater than or equal to %2$s. Got: %s',
426
                static::valueToString($value),
427
                static::valueToString($limit)
428
            ));
429
        }
430
    }
431
432
    public static function lessThan($value, $limit, $message = '')
433
    {
@@ 432-441 (lines=10) @@
429
        }
430
    }
431
432
    public static function lessThan($value, $limit, $message = '')
433
    {
434
        if ($value >= $limit) {
435
            static::reportInvalidArgument(sprintf(
436
                $message ?: 'Expected a value less than %2$s. Got: %s',
437
                static::valueToString($value),
438
                static::valueToString($limit)
439
            ));
440
        }
441
    }
442
443
    public static function lessThanEq($value, $limit, $message = '')
444
    {
@@ 443-452 (lines=10) @@
440
        }
441
    }
442
443
    public static function lessThanEq($value, $limit, $message = '')
444
    {
445
        if ($value > $limit) {
446
            static::reportInvalidArgument(sprintf(
447
                $message ?: 'Expected a value less than or equal to %2$s. Got: %s',
448
                static::valueToString($value),
449
                static::valueToString($limit)
450
            ));
451
        }
452
    }
453
454
    public static function range($value, $min, $max, $message = '')
455
    {
@@ 488-496 (lines=9) @@
485
        }
486
    }
487
488
    public static function notWhitespace($value, $message = '')
489
    {
490
        if (preg_match('/^\s*$/', $value)) {
491
            static::reportInvalidArgument(sprintf(
492
                $message ?: 'Expected a non-whitespace string. Got: %s',
493
                static::valueToString($value)
494
            ));
495
        }
496
    }
497
498
    public static function startsWith($value, $prefix, $message = '')
499
    {
@@ 539-547 (lines=9) @@
536
        }
537
    }
538
539
    public static function regex($value, $pattern, $message = '')
540
    {
541
        if (!preg_match($pattern, $value)) {
542
            static::reportInvalidArgument(sprintf(
543
                $message ?: 'The value %s does not match the expected pattern.',
544
                static::valueToString($value)
545
            ));
546
        }
547
    }
548
549
    public static function alpha($value, $message = '')
550
    {
@@ 635-644 (lines=10) @@
632
        }
633
    }
634
635
    public static function minLength($value, $min, $message = '')
636
    {
637
        if (static::strlen($value) < $min) {
638
            static::reportInvalidArgument(sprintf(
639
                $message ?: 'Expected a value to contain at least %2$s characters. Got: %s',
640
                static::valueToString($value),
641
                $min
642
            ));
643
        }
644
    }
645
646
    public static function maxLength($value, $max, $message = '')
647
    {
@@ 646-655 (lines=10) @@
643
        }
644
    }
645
646
    public static function maxLength($value, $max, $message = '')
647
    {
648
        if (static::strlen($value) > $max) {
649
            static::reportInvalidArgument(sprintf(
650
                $message ?: 'Expected a value to contain at most %2$s characters. Got: %s',
651
                static::valueToString($value),
652
                $max
653
            ));
654
        }
655
    }
656
657
    public static function lengthBetween($value, $min, $max, $message = '')
658
    {
@@ 707-715 (lines=9) @@
704
        }
705
    }
706
707
    public static function readable($value, $message = '')
708
    {
709
        if (!is_readable($value)) {
710
            static::reportInvalidArgument(sprintf(
711
                $message ?: 'The path %s is not readable.',
712
                static::valueToString($value)
713
            ));
714
        }
715
    }
716
717
    public static function writable($value, $message = '')
718
    {
@@ 717-725 (lines=9) @@
714
        }
715
    }
716
717
    public static function writable($value, $message = '')
718
    {
719
        if (!is_writable($value)) {
720
            static::reportInvalidArgument(sprintf(
721
                $message ?: 'The path %s is not writable.',
722
                static::valueToString($value)
723
            ));
724
        }
725
    }
726
727
    public static function classExists($value, $message = '')
728
    {
@@ 727-735 (lines=9) @@
724
        }
725
    }
726
727
    public static function classExists($value, $message = '')
728
    {
729
        if (!class_exists($value)) {
730
            static::reportInvalidArgument(sprintf(
731
                $message ?: 'Expected an existing class name. Got: %s',
732
                static::valueToString($value)
733
            ));
734
        }
735
    }
736
737
    public static function subclassOf($value, $class, $message = '')
738
    {