Code Duplication    Length = 9-10 lines in 6 locations

src/Assert.php 6 locations

@@ 637-645 (lines=9) @@
634
     *
635
     * @throws InvalidArgumentException
636
     */
637
    public static function null($value, $message = '')
638
    {
639
        if (null !== $value) {
640
            static::reportInvalidArgument(\sprintf(
641
                $message ?: 'Expected null. Got: %s',
642
                static::valueToString($value)
643
            ));
644
        }
645
    }
646
647
    /**
648
     * @psalm-pure
@@ 674-682 (lines=9) @@
671
     *
672
     * @throws InvalidArgumentException
673
     */
674
    public static function true($value, $message = '')
675
    {
676
        if (true !== $value) {
677
            static::reportInvalidArgument(\sprintf(
678
                $message ?: 'Expected a value to be true. Got: %s',
679
                static::valueToString($value)
680
            ));
681
        }
682
    }
683
684
    /**
685
     * @psalm-pure
@@ 693-701 (lines=9) @@
690
     *
691
     * @throws InvalidArgumentException
692
     */
693
    public static function false($value, $message = '')
694
    {
695
        if (false !== $value) {
696
            static::reportInvalidArgument(\sprintf(
697
                $message ?: 'Expected a value to be false. Got: %s',
698
                static::valueToString($value)
699
            ));
700
        }
701
    }
702
703
    /**
704
     * @psalm-pure
@@ 1380-1389 (lines=10) @@
1377
     *
1378
     * @throws InvalidArgumentException
1379
     */
1380
    public static function length($value, $length, $message = '')
1381
    {
1382
        if ($length !== static::strlen($value)) {
1383
            static::reportInvalidArgument(\sprintf(
1384
                $message ?: 'Expected a value to contain %2$s characters. Got: %s',
1385
                static::valueToString($value),
1386
                $length
1387
            ));
1388
        }
1389
    }
1390
1391
    /**
1392
     * Inclusive min.
@@ 1402-1411 (lines=10) @@
1399
     *
1400
     * @throws InvalidArgumentException
1401
     */
1402
    public static function minLength($value, $min, $message = '')
1403
    {
1404
        if (static::strlen($value) < $min) {
1405
            static::reportInvalidArgument(\sprintf(
1406
                $message ?: 'Expected a value to contain at least %2$s characters. Got: %s',
1407
                static::valueToString($value),
1408
                $min
1409
            ));
1410
        }
1411
    }
1412
1413
    /**
1414
     * Inclusive max.
@@ 1424-1433 (lines=10) @@
1421
     *
1422
     * @throws InvalidArgumentException
1423
     */
1424
    public static function maxLength($value, $max, $message = '')
1425
    {
1426
        if (static::strlen($value) > $max) {
1427
            static::reportInvalidArgument(\sprintf(
1428
                $message ?: 'Expected a value to contain at most %2$s characters. Got: %s',
1429
                static::valueToString($value),
1430
                $max
1431
            ));
1432
        }
1433
    }
1434
1435
    /**
1436
     * Inclusive , so Assert::lengthBetween('asd', 3, 5); passes the assertion.