Code Duplication    Length = 9-10 lines in 16 locations

src/Assert.php 16 locations

@@ 285-294 (lines=10) @@
282
        {
283
            return $this;
284
        }
285
        if ( $this->value != $value2 )
286
        {
287
            $message = $message ?: $this->overrideError;
288
            $message = sprintf(
289
                $message ?: 'Value "%s" does not equal expected value "%s".',
290
                $this->stringify($this->value),
291
                $this->stringify($value2)
292
            );
293
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $propertyPath, ['expected' => $value2]);
294
        }
295
        return $this;
296
    }
297
@@ 312-321 (lines=10) @@
309
        {
310
            return $this;
311
        }
312
        if ( ! ( $this->value > $value2 ) )
313
        {
314
            $message = $message ?: $this->overrideError;
315
            $message = sprintf(
316
                $message ?: 'Value "%s" does not greater then expected value "%s".',
317
                $this->stringify($this->value),
318
                $this->stringify($value2)
319
            );
320
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $propertyPath, ['expected' => $value2]);
321
        }
322
        return $this;
323
    }
324
@@ 339-348 (lines=10) @@
336
        {
337
            return $this;
338
        }
339
        if ( ! ( $this->value >= $value2 ) )
340
        {
341
            $message = $message ?: $this->overrideError;
342
            $message = sprintf(
343
                $message ?: 'Value "%s" does not greater than or equal to expected value "%s".',
344
                $this->stringify($this->value),
345
                $this->stringify($value2)
346
            );
347
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $propertyPath, ['expected' => $value2]);
348
        }
349
        return $this;
350
    }
351
@@ 366-375 (lines=10) @@
363
        {
364
            return $this;
365
        }
366
        if ( ! ( $this->value < $value2 ) )
367
        {
368
            $message = $message ?: $this->overrideError;
369
            $message = sprintf(
370
                $message ?: 'Value "%s" does not less then expected value "%s".',
371
                $this->stringify($this->value),
372
                $this->stringify($value2)
373
            );
374
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN, $propertyPath, ['expected' => $value2]);
375
        }
376
        return $this;
377
    }
378
@@ 393-402 (lines=10) @@
390
        {
391
            return $this;
392
        }
393
        if ( ! ( $this->value <= $value2 ) )
394
        {
395
            $message = $message ?: $this->overrideError;
396
            $message = sprintf(
397
                $message ?: 'Value "%s" does not less than or equal to expected value "%s".',
398
                $this->stringify($this->value),
399
                $this->stringify($value2)
400
            );
401
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN_OR_EQ, $propertyPath, ['expected' => $value2]);
402
        }
403
        return $this;
404
    }
405
@@ 421-430 (lines=10) @@
418
        {
419
            return $this;
420
        }
421
        if ( $this->value !== $value2 )
422
        {
423
            $message = $message ?: $this->overrideError;
424
            $message = sprintf(
425
                $message ?: 'Value "%s" is not the same as expected value "%s".',
426
                $this->stringify($this->value),
427
                $this->stringify($value2)
428
            );
429
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SAME, $propertyPath, ['expected' => $value2]);
430
        }
431
        return $this;
432
    }
433
@@ 449-458 (lines=10) @@
446
        {
447
            return $this;
448
        }
449
        if ( $this->value == $value2 )
450
        {
451
            $message = $message ?: $this->overrideError;
452
            $message = sprintf(
453
                $message ?: 'Value "%s" is equal to expected value "%s".',
454
                $this->stringify($this->value),
455
                $this->stringify($value2)
456
            );
457
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_EQ, $propertyPath, ['expected' => $value2]);
458
        }
459
        return $this;
460
    }
461
@@ 502-511 (lines=10) @@
499
        {
500
            return $this;
501
        }
502
        if ( $this->value === $value2 )
503
        {
504
            $message = $message ?: $this->overrideError;
505
            $message = sprintf(
506
                $message ?: 'Value "%s" is the same as expected value "%s".',
507
                $this->stringify($this->value),
508
                $this->stringify($value2)
509
            );
510
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_SAME, $propertyPath, ['expected' => $value2]);
511
        }
512
        return $this;
513
    }
514
@@ 889-897 (lines=9) @@
886
            return $this;
887
        }
888
        $this->string($message, $propertyPath);
889
        if ( ! preg_match($pattern, $this->value) )
890
        {
891
            $message = $message ?: $this->overrideError;
892
            $message = sprintf(
893
                $message ?: 'Value "%s" does not match expression.',
894
                $this->stringify($this->value)
895
            );
896
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]);
897
        }
898
        return $this;
899
    }
900
@@ 941-949 (lines=9) @@
938
            return $this;
939
        }
940
        $this->string($message, $propertyPath);
941
        if ( preg_match($pattern, $this->value) )
942
        {
943
            $message = $message ?: $this->overrideError;
944
            $message = sprintf(
945
                $message ?: 'Value "%s" does not match expression.',
946
                $this->stringify($this->value)
947
            );
948
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]);
949
        }
950
        return $this;
951
    }
952
@@ 1641-1650 (lines=10) @@
1638
        {
1639
            return $this;
1640
        }
1641
        if ( !( $this->value instanceof $className ) )
1642
        {
1643
            $message = $message ?: $this->overrideError;
1644
            $message = sprintf(
1645
                $message ?: 'Class "%s" was expected to be instanceof of "%s" but is not.',
1646
                $this->stringify($this->value),
1647
                $className
1648
            );
1649
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_INSTANCE_OF, $propertyPath, ['class' => $className]);
1650
        }
1651
        return $this;
1652
    }
1653
@@ 1669-1678 (lines=10) @@
1666
        {
1667
            return $this;
1668
        }
1669
        if ( $this->value instanceof $className )
1670
        {
1671
            $message = $message ?: $this->overrideError;
1672
            $message = sprintf(
1673
                $message ?: 'Class "%s" was not expected to be instanceof of "%s".',
1674
                $this->stringify($this->value),
1675
                $className
1676
            );
1677
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_INSTANCE_OF, $propertyPath, ['class' => $className]);
1678
        }
1679
        return $this;
1680
    }
1681
@@ 1697-1706 (lines=10) @@
1694
        {
1695
            return $this;
1696
        }
1697
        if ( !is_subclass_of($this->value, $className) )
1698
        {
1699
            $message = $message ?: $this->overrideError;
1700
            $message = sprintf(
1701
                $message ?: 'Class "%s" was expected to be subclass of "%s".',
1702
                $this->stringify($this->value),
1703
                $className
1704
            );
1705
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SUBCLASS_OF, $propertyPath, ['class' => $className]);
1706
        }
1707
        return $this;
1708
    }
1709
@@ 1760-1769 (lines=10) @@
1757
            return $this;
1758
        }
1759
        $this->numeric($message, $propertyPath);
1760
        if ( $this->value < $minValue )
1761
        {
1762
            $message = $message ?: $this->overrideError;
1763
            $message = sprintf(
1764
                $message ?: 'Number "%s" was expected to be at least "%d".',
1765
                $this->stringify($this->value),
1766
                $this->stringify($minValue)
1767
            );
1768
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN, $propertyPath, ['min' => $minValue]);
1769
        }
1770
        return $this;
1771
    }
1772
@@ 1789-1798 (lines=10) @@
1786
            return $this;
1787
        }
1788
        $this->numeric($message, $propertyPath);
1789
        if ( $this->value > $maxValue )
1790
        {
1791
            $message = $message ?: $this->overrideError;
1792
            $message = sprintf(
1793
                $message ?: 'Number "%s" was expected to be at most "%d".',
1794
                $this->stringify($this->value),
1795
                $this->stringify($maxValue)
1796
            );
1797
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX, $propertyPath, ['max' => $maxValue]);
1798
        }
1799
        return $this;
1800
    }
1801
@@ 2341-2350 (lines=10) @@
2338
        {
2339
            return $this;
2340
        }
2341
        if ( $count !== count($this->value) )
2342
        {
2343
            $message = $message ?: $this->overrideError;
2344
            $message = sprintf(
2345
                $message ?: 'List does not contain exactly "%d" elements.',
2346
                $this->stringify($this->value),
2347
                $this->stringify($count)
2348
            );
2349
            throw $this->createException($message, $this->overrideCode ?: self::INVALID_COUNT, $propertyPath, ['count' => $count]);
2350
        }
2351
        return $this;
2352
    }
2353