Code Duplication    Length = 9-10 lines in 16 locations

src/Assert.php 16 locations

@@ 366-374 (lines=9) @@
363
        }
364
    }
365
366
    public static function null($value, $message = '')
367
    {
368
        if (null !== $value) {
369
            static::reportInvalidArgument(sprintf(
370
                $message ?: 'Expected null. Got: %s',
371
                static::valueToString($value)
372
            ));
373
        }
374
    }
375
376
    public static function notNull($value, $message = '')
377
    {
@@ 385-393 (lines=9) @@
382
        }
383
    }
384
385
    public static function true($value, $message = '')
386
    {
387
        if (true !== $value) {
388
            static::reportInvalidArgument(sprintf(
389
                $message ?: 'Expected a value to be true. Got: %s',
390
                static::valueToString($value)
391
            ));
392
        }
393
    }
394
395
    public static function false($value, $message = '')
396
    {
@@ 395-403 (lines=9) @@
392
        }
393
    }
394
395
    public static function false($value, $message = '')
396
    {
397
        if (false !== $value) {
398
            static::reportInvalidArgument(sprintf(
399
                $message ?: 'Expected a value to be false. Got: %s',
400
                static::valueToString($value)
401
            ));
402
        }
403
    }
404
405
    public static function eq($value, $value2, $message = '')
406
    {
@@ 405-414 (lines=10) @@
402
        }
403
    }
404
405
    public static function eq($value, $value2, $message = '')
406
    {
407
        if ($value2 != $value) {
408
            static::reportInvalidArgument(sprintf(
409
                $message ?: 'Expected a value equal to %2$s. Got: %s',
410
                static::valueToString($value),
411
                static::valueToString($value2)
412
            ));
413
        }
414
    }
415
416
    public static function notEq($value, $value2, $message = '')
417
    {
@@ 426-435 (lines=10) @@
423
        }
424
    }
425
426
    public static function same($value, $value2, $message = '')
427
    {
428
        if ($value2 !== $value) {
429
            static::reportInvalidArgument(sprintf(
430
                $message ?: 'Expected a value identical to %2$s. Got: %s',
431
                static::valueToString($value),
432
                static::valueToString($value2)
433
            ));
434
        }
435
    }
436
437
    public static function notSame($value, $value2, $message = '')
438
    {
@@ 447-456 (lines=10) @@
444
        }
445
    }
446
447
    public static function greaterThan($value, $limit, $message = '')
448
    {
449
        if ($value <= $limit) {
450
            static::reportInvalidArgument(sprintf(
451
                $message ?: 'Expected a value greater than %2$s. Got: %s',
452
                static::valueToString($value),
453
                static::valueToString($limit)
454
            ));
455
        }
456
    }
457
458
    public static function greaterThanEq($value, $limit, $message = '')
459
    {
@@ 458-467 (lines=10) @@
455
        }
456
    }
457
458
    public static function greaterThanEq($value, $limit, $message = '')
459
    {
460
        if ($value < $limit) {
461
            static::reportInvalidArgument(sprintf(
462
                $message ?: 'Expected a value greater than or equal to %2$s. Got: %s',
463
                static::valueToString($value),
464
                static::valueToString($limit)
465
            ));
466
        }
467
    }
468
469
    public static function lessThan($value, $limit, $message = '')
470
    {
@@ 469-478 (lines=10) @@
466
        }
467
    }
468
469
    public static function lessThan($value, $limit, $message = '')
470
    {
471
        if ($value >= $limit) {
472
            static::reportInvalidArgument(sprintf(
473
                $message ?: 'Expected a value less than %2$s. Got: %s',
474
                static::valueToString($value),
475
                static::valueToString($limit)
476
            ));
477
        }
478
    }
479
480
    public static function lessThanEq($value, $limit, $message = '')
481
    {
@@ 480-489 (lines=10) @@
477
        }
478
    }
479
480
    public static function lessThanEq($value, $limit, $message = '')
481
    {
482
        if ($value > $limit) {
483
            static::reportInvalidArgument(sprintf(
484
                $message ?: 'Expected a value less than or equal to %2$s. Got: %s',
485
                static::valueToString($value),
486
                static::valueToString($limit)
487
            ));
488
        }
489
    }
490
491
    public static function range($value, $min, $max, $message = '')
492
    {
@@ 525-533 (lines=9) @@
522
        }
523
    }
524
525
    public static function notWhitespaceOnly($value, $message = '')
526
    {
527
        if (preg_match('/^\s*$/', $value)) {
528
            static::reportInvalidArgument(sprintf(
529
                $message ?: 'Expected a non-whitespace string. Got: %s',
530
                static::valueToString($value)
531
            ));
532
        }
533
    }
534
535
    public static function startsWith($value, $prefix, $message = '')
536
    {
@@ 576-584 (lines=9) @@
573
        }
574
    }
575
576
    public static function regex($value, $pattern, $message = '')
577
    {
578
        if (!preg_match($pattern, $value)) {
579
            static::reportInvalidArgument(sprintf(
580
                $message ?: 'The value %s does not match the expected pattern.',
581
                static::valueToString($value)
582
            ));
583
        }
584
    }
585
586
    public static function alpha($value, $message = '')
587
    {
@@ 672-681 (lines=10) @@
669
        }
670
    }
671
672
    public static function minLength($value, $min, $message = '')
673
    {
674
        if (static::strlen($value) < $min) {
675
            static::reportInvalidArgument(sprintf(
676
                $message ?: 'Expected a value to contain at least %2$s characters. Got: %s',
677
                static::valueToString($value),
678
                $min
679
            ));
680
        }
681
    }
682
683
    public static function maxLength($value, $max, $message = '')
684
    {
@@ 683-692 (lines=10) @@
680
        }
681
    }
682
683
    public static function maxLength($value, $max, $message = '')
684
    {
685
        if (static::strlen($value) > $max) {
686
            static::reportInvalidArgument(sprintf(
687
                $message ?: 'Expected a value to contain at most %2$s characters. Got: %s',
688
                static::valueToString($value),
689
                $max
690
            ));
691
        }
692
    }
693
694
    public static function lengthBetween($value, $min, $max, $message = '')
695
    {
@@ 744-752 (lines=9) @@
741
        }
742
    }
743
744
    public static function readable($value, $message = '')
745
    {
746
        if (!is_readable($value)) {
747
            static::reportInvalidArgument(sprintf(
748
                $message ?: 'The path %s is not readable.',
749
                static::valueToString($value)
750
            ));
751
        }
752
    }
753
754
    public static function writable($value, $message = '')
755
    {
@@ 754-762 (lines=9) @@
751
        }
752
    }
753
754
    public static function writable($value, $message = '')
755
    {
756
        if (!is_writable($value)) {
757
            static::reportInvalidArgument(sprintf(
758
                $message ?: 'The path %s is not writable.',
759
                static::valueToString($value)
760
            ));
761
        }
762
    }
763
764
    public static function classExists($value, $message = '')
765
    {
@@ 764-772 (lines=9) @@
761
        }
762
    }
763
764
    public static function classExists($value, $message = '')
765
    {
766
        if (!class_exists($value)) {
767
            static::reportInvalidArgument(sprintf(
768
                $message ?: 'Expected an existing class name. Got: %s',
769
                static::valueToString($value)
770
            ));
771
        }
772
    }
773
774
    public static function subclassOf($value, $class, $message = '')
775
    {