Complex classes like Assertion often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Assertion, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 146 | class Assertion  | 
            ||
| 147 | { | 
            ||
| 148 | const INVALID_FLOAT = 9;  | 
            ||
| 149 | const INVALID_INTEGER = 10;  | 
            ||
| 150 | const INVALID_DIGIT = 11;  | 
            ||
| 151 | const INVALID_INTEGERISH = 12;  | 
            ||
| 152 | const INVALID_BOOLEAN = 13;  | 
            ||
| 153 | const VALUE_EMPTY = 14;  | 
            ||
| 154 | const VALUE_NULL = 15;  | 
            ||
| 155 | const INVALID_STRING = 16;  | 
            ||
| 156 | const INVALID_REGEX = 17;  | 
            ||
| 157 | const INVALID_MIN_LENGTH = 18;  | 
            ||
| 158 | const INVALID_MAX_LENGTH = 19;  | 
            ||
| 159 | const INVALID_STRING_START = 20;  | 
            ||
| 160 | const INVALID_STRING_CONTAINS = 21;  | 
            ||
| 161 | const INVALID_CHOICE = 22;  | 
            ||
| 162 | const INVALID_NUMERIC = 23;  | 
            ||
| 163 | const INVALID_ARRAY = 24;  | 
            ||
| 164 | const INVALID_KEY_EXISTS = 26;  | 
            ||
| 165 | const INVALID_NOT_BLANK = 27;  | 
            ||
| 166 | const INVALID_INSTANCE_OF = 28;  | 
            ||
| 167 | const INVALID_SUBCLASS_OF = 29;  | 
            ||
| 168 | const INVALID_RANGE = 30;  | 
            ||
| 169 | const INVALID_ALNUM = 31;  | 
            ||
| 170 | const INVALID_TRUE = 32;  | 
            ||
| 171 | const INVALID_EQ = 33;  | 
            ||
| 172 | const INVALID_SAME = 34;  | 
            ||
| 173 | const INVALID_MIN = 35;  | 
            ||
| 174 | const INVALID_MAX = 36;  | 
            ||
| 175 | const INVALID_LENGTH = 37;  | 
            ||
| 176 | const INVALID_FALSE = 38;  | 
            ||
| 177 | const INVALID_STRING_END = 39;  | 
            ||
| 178 | const INVALID_UUID = 40;  | 
            ||
| 179 | const INVALID_COUNT = 41;  | 
            ||
| 180 | const INVALID_NOT_EQ = 42;  | 
            ||
| 181 | const INVALID_NOT_SAME = 43;  | 
            ||
| 182 | const INVALID_TRAVERSABLE = 44;  | 
            ||
| 183 | const INVALID_ARRAY_ACCESSIBLE = 45;  | 
            ||
| 184 | const INVALID_KEY_ISSET = 46;  | 
            ||
| 185 | const INVALID_VALUE_IN_ARRAY = 47;  | 
            ||
| 186 | const INVALID_DIRECTORY = 101;  | 
            ||
| 187 | const INVALID_FILE = 102;  | 
            ||
| 188 | const INVALID_READABLE = 103;  | 
            ||
| 189 | const INVALID_WRITEABLE = 104;  | 
            ||
| 190 | const INVALID_CLASS = 105;  | 
            ||
| 191 | const INVALID_EMAIL = 201;  | 
            ||
| 192 | const INTERFACE_NOT_IMPLEMENTED = 202;  | 
            ||
| 193 | const INVALID_URL = 203;  | 
            ||
| 194 | const INVALID_NOT_INSTANCE_OF = 204;  | 
            ||
| 195 | const VALUE_NOT_EMPTY = 205;  | 
            ||
| 196 | const INVALID_JSON_STRING = 206;  | 
            ||
| 197 | const INVALID_OBJECT = 207;  | 
            ||
| 198 | const INVALID_METHOD = 208;  | 
            ||
| 199 | const INVALID_SCALAR = 209;  | 
            ||
| 200 | const INVALID_LESS = 210;  | 
            ||
| 201 | const INVALID_LESS_OR_EQUAL = 211;  | 
            ||
| 202 | const INVALID_GREATER = 212;  | 
            ||
| 203 | const INVALID_GREATER_OR_EQUAL = 212;  | 
            ||
| 204 | const INVALID_DATE = 213;  | 
            ||
| 205 | const INVALID_CALLABLE = 214;  | 
            ||
| 206 | |||
| 207 | /**  | 
            ||
| 208 | * Exception to throw when an assertion failed.  | 
            ||
| 209 | *  | 
            ||
| 210 | * @var string  | 
            ||
| 211 | */  | 
            ||
| 212 | static protected $exceptionClass = 'Assert\InvalidArgumentException';  | 
            ||
| 213 | |||
| 214 | /**  | 
            ||
| 215 | * Helper method that handles building the assertion failure exceptions.  | 
            ||
| 216 | * They are returned from this method so that the stack trace still shows  | 
            ||
| 217 | * the assertions method.  | 
            ||
| 218 | */  | 
            ||
| 219 | protected static function createException($value, $message, $code, $propertyPath, array $constraints = array())  | 
            ||
| 224 | |||
| 225 | /**  | 
            ||
| 226 | * Assert that two values are equal (using == ).  | 
            ||
| 227 | *  | 
            ||
| 228 | * @param mixed $value  | 
            ||
| 229 | * @param mixed $value2  | 
            ||
| 230 | * @param string|null $message  | 
            ||
| 231 | * @param string|null $propertyPath  | 
            ||
| 232 | * @return void  | 
            ||
| 233 | * @throws \Assert\AssertionFailedException  | 
            ||
| 234 | */  | 
            ||
| 235 | public static function eq($value, $value2, $message = null, $propertyPath = null)  | 
            ||
| 247 | |||
| 248 | /**  | 
            ||
| 249 | * Assert that two values are the same (using ===).  | 
            ||
| 250 | *  | 
            ||
| 251 | * @param mixed $value  | 
            ||
| 252 | * @param mixed $value2  | 
            ||
| 253 | * @param string|null $message  | 
            ||
| 254 | * @param string|null $propertyPath  | 
            ||
| 255 | * @return void  | 
            ||
| 256 | * @throws \Assert\AssertionFailedException  | 
            ||
| 257 | */  | 
            ||
| 258 | public static function same($value, $value2, $message = null, $propertyPath = null)  | 
            ||
| 270 | |||
| 271 | /**  | 
            ||
| 272 | * Assert that two values are not equal (using == ).  | 
            ||
| 273 | *  | 
            ||
| 274 | * @param mixed $value1  | 
            ||
| 275 | * @param mixed $value2  | 
            ||
| 276 | * @param string|null $message  | 
            ||
| 277 | * @param string|null $propertyPath  | 
            ||
| 278 | * @return void  | 
            ||
| 279 | * @throws \Assert\AssertionFailedException  | 
            ||
| 280 | */  | 
            ||
| 281 | public static function notEq($value1, $value2, $message = null, $propertyPath = null)  | 
            ||
| 292 | |||
| 293 | /**  | 
            ||
| 294 | * Assert that two values are not the same (using === ).  | 
            ||
| 295 | *  | 
            ||
| 296 | * @param mixed $value1  | 
            ||
| 297 | * @param mixed $value2  | 
            ||
| 298 | * @param string|null $message  | 
            ||
| 299 | * @param string|null $propertyPath  | 
            ||
| 300 | * @return void  | 
            ||
| 301 | * @throws \Assert\AssertionFailedException  | 
            ||
| 302 | */  | 
            ||
| 303 | public static function notSame($value1, $value2, $message = null, $propertyPath = null)  | 
            ||
| 314 | |||
| 315 | /**  | 
            ||
| 316 | * Assert that value is not in array of choices.  | 
            ||
| 317 | *  | 
            ||
| 318 | * @param mixed $value1  | 
            ||
| 319 | * @param array $choices  | 
            ||
| 320 | * @param string|null $message  | 
            ||
| 321 | * @param string|null $propertyPath  | 
            ||
| 322 | * @return void  | 
            ||
| 323 | * @throws \Assert\AssertionFailedException  | 
            ||
| 324 | */  | 
            ||
| 325 | public static function notInArray($value1, array $choices, $message = null, $propertyPath = null)  | 
            ||
| 336 | |||
| 337 | /**  | 
            ||
| 338 | * Assert that value is a php integer.  | 
            ||
| 339 | *  | 
            ||
| 340 | * @param mixed $value  | 
            ||
| 341 | * @param string|null $message  | 
            ||
| 342 | * @param string|null $propertyPath  | 
            ||
| 343 | * @return void  | 
            ||
| 344 | * @throws \Assert\AssertionFailedException  | 
            ||
| 345 | */  | 
            ||
| 346 | public static function integer($value, $message = null, $propertyPath = null)  | 
            ||
| 357 | |||
| 358 | /**  | 
            ||
| 359 | * Assert that value is a php float.  | 
            ||
| 360 | *  | 
            ||
| 361 | * @param mixed $value  | 
            ||
| 362 | * @param string|null $message  | 
            ||
| 363 | * @param string|null $propertyPath  | 
            ||
| 364 | * @return void  | 
            ||
| 365 | * @throws \Assert\AssertionFailedException  | 
            ||
| 366 | */  | 
            ||
| 367 | public static function float($value, $message = null, $propertyPath = null)  | 
            ||
| 378 | |||
| 379 | /**  | 
            ||
| 380 | * Validates if an integer or integerish is a digit.  | 
            ||
| 381 | *  | 
            ||
| 382 | * @param mixed $value  | 
            ||
| 383 | * @param string|null $message  | 
            ||
| 384 | * @param string|null $propertyPath  | 
            ||
| 385 | * @return void  | 
            ||
| 386 | * @throws \Assert\AssertionFailedException  | 
            ||
| 387 | */  | 
            ||
| 388 | public static function digit($value, $message = null, $propertyPath = null)  | 
            ||
| 399 | |||
| 400 | /**  | 
            ||
| 401 | * Assert that value is a php integer'ish.  | 
            ||
| 402 | *  | 
            ||
| 403 | * @param mixed $value  | 
            ||
| 404 | * @param string|null $message  | 
            ||
| 405 | * @param string|null $propertyPath  | 
            ||
| 406 | * @return void  | 
            ||
| 407 | * @throws \Assert\AssertionFailedException  | 
            ||
| 408 | */  | 
            ||
| 409 | public static function integerish($value, $message = null, $propertyPath = null)  | 
            ||
| 420 | |||
| 421 | /**  | 
            ||
| 422 | * Assert that value is php boolean  | 
            ||
| 423 | *  | 
            ||
| 424 | * @param mixed $value  | 
            ||
| 425 | * @param string|null $message  | 
            ||
| 426 | * @param string|null $propertyPath  | 
            ||
| 427 | * @return void  | 
            ||
| 428 | * @throws \Assert\AssertionFailedException  | 
            ||
| 429 | */  | 
            ||
| 430 | public static function boolean($value, $message = null, $propertyPath = null)  | 
            ||
| 441 | |||
| 442 | /**  | 
            ||
| 443 | * Assert that value is a PHP scalar  | 
            ||
| 444 | *  | 
            ||
| 445 | * @param mixed $value  | 
            ||
| 446 | * @param string|null $message  | 
            ||
| 447 | * @param string|null $propertyPath  | 
            ||
| 448 | * @return void  | 
            ||
| 449 | * @throws \Assert\AssertionFailedException  | 
            ||
| 450 | */  | 
            ||
| 451 | public static function scalar($value, $message = null, $propertyPath = null)  | 
            ||
| 462 | |||
| 463 | /**  | 
            ||
| 464 | * Assert that value is not empty  | 
            ||
| 465 | *  | 
            ||
| 466 | * @param mixed $value  | 
            ||
| 467 | * @param string|null $message  | 
            ||
| 468 | * @param string|null $propertyPath  | 
            ||
| 469 | * @return void  | 
            ||
| 470 | * @throws \Assert\AssertionFailedException  | 
            ||
| 471 | */  | 
            ||
| 472 | public static function notEmpty($value, $message = null, $propertyPath = null)  | 
            ||
| 483 | |||
| 484 | /**  | 
            ||
| 485 | * Assert that value is empty  | 
            ||
| 486 | *  | 
            ||
| 487 | * @param mixed $value  | 
            ||
| 488 | * @param string|null $message  | 
            ||
| 489 | * @param string|null $propertyPath  | 
            ||
| 490 | * @return void  | 
            ||
| 491 | * @throws \Assert\AssertionFailedException  | 
            ||
| 492 | */  | 
            ||
| 493 | public static function noContent($value, $message = null, $propertyPath = null)  | 
            ||
| 504 | |||
| 505 | /**  | 
            ||
| 506 | * Assert that value is not null  | 
            ||
| 507 | *  | 
            ||
| 508 | * @param mixed $value  | 
            ||
| 509 | * @param string|null $message  | 
            ||
| 510 | * @param string|null $propertyPath  | 
            ||
| 511 | * @return void  | 
            ||
| 512 | * @throws \Assert\AssertionFailedException  | 
            ||
| 513 | */  | 
            ||
| 514 | public static function notNull($value, $message = null, $propertyPath = null)  | 
            ||
| 525 | |||
| 526 | /**  | 
            ||
| 527 | * Assert that value is a string  | 
            ||
| 528 | *  | 
            ||
| 529 | * @param mixed $value  | 
            ||
| 530 | * @param string|null $message  | 
            ||
| 531 | * @param string|null $propertyPath  | 
            ||
| 532 | * @return void  | 
            ||
| 533 | * @throws \Assert\AssertionFailedException  | 
            ||
| 534 | */  | 
            ||
| 535 | public static function string($value, $message = null, $propertyPath = null)  | 
            ||
| 547 | |||
| 548 | /**  | 
            ||
| 549 | * Assert that value matches a regex  | 
            ||
| 550 | *  | 
            ||
| 551 | * @param mixed $value  | 
            ||
| 552 | * @param string $pattern  | 
            ||
| 553 | * @param string|null $message  | 
            ||
| 554 | * @param string|null $propertyPath  | 
            ||
| 555 | * @return void  | 
            ||
| 556 | * @throws \Assert\AssertionFailedException  | 
            ||
| 557 | */  | 
            ||
| 558 | public static function regex($value, $pattern, $message = null, $propertyPath = null)  | 
            ||
| 571 | |||
| 572 | /**  | 
            ||
| 573 | * Assert that string has a given length.  | 
            ||
| 574 | *  | 
            ||
| 575 | * @param mixed $value  | 
            ||
| 576 | * @param int $length  | 
            ||
| 577 | * @param string|null $message  | 
            ||
| 578 | * @param string|null $propertyPath  | 
            ||
| 579 | * @param string $encoding  | 
            ||
| 580 | * @return void  | 
            ||
| 581 | * @throws \Assert\AssertionFailedException  | 
            ||
| 582 | */  | 
            ||
| 583 | public static function length($value, $length, $message = null, $propertyPath = null, $encoding = 'utf8')  | 
            ||
| 599 | |||
| 600 | /**  | 
            ||
| 601 | * Assert that a string is at least $minLength chars long.  | 
            ||
| 602 | *  | 
            ||
| 603 | * @param mixed $value  | 
            ||
| 604 | * @param int $minLength  | 
            ||
| 605 | * @param string|null $message  | 
            ||
| 606 | * @param string|null $propertyPath  | 
            ||
| 607 | * @param string $encoding  | 
            ||
| 608 | * @return void  | 
            ||
| 609 | * @throws \Assert\AssertionFailedException  | 
            ||
| 610 | */  | 
            ||
| 611 | public static function minLength($value, $minLength, $message = null, $propertyPath = null, $encoding = 'utf8')  | 
            ||
| 627 | |||
| 628 | /**  | 
            ||
| 629 | * Assert that string value is not longer than $maxLength chars.  | 
            ||
| 630 | *  | 
            ||
| 631 | * @param mixed $value  | 
            ||
| 632 | * @param integer $maxLength  | 
            ||
| 633 | * @param string|null $message  | 
            ||
| 634 | * @param string|null $propertyPath  | 
            ||
| 635 | * @param string $encoding  | 
            ||
| 636 | * @return void  | 
            ||
| 637 | * @throws \Assert\AssertionFailedException  | 
            ||
| 638 | */  | 
            ||
| 639 | public static function maxLength($value, $maxLength, $message = null, $propertyPath = null, $encoding = 'utf8')  | 
            ||
| 655 | |||
| 656 | /**  | 
            ||
| 657 | * Assert that string length is between min,max lengths.  | 
            ||
| 658 | *  | 
            ||
| 659 | * @param mixed $value  | 
            ||
| 660 | * @param integer $minLength  | 
            ||
| 661 | * @param integer $maxLength  | 
            ||
| 662 | * @param string|null $message  | 
            ||
| 663 | * @param string|null $propertyPath  | 
            ||
| 664 | * @param string $encoding  | 
            ||
| 665 | * @return void  | 
            ||
| 666 | * @throws \Assert\AssertionFailedException  | 
            ||
| 667 | */  | 
            ||
| 668 | public static function betweenLength($value, $minLength, $maxLength, $message = null, $propertyPath = null, $encoding = 'utf8')  | 
            ||
| 696 | |||
| 697 | /**  | 
            ||
| 698 | * Assert that string starts with a sequence of chars.  | 
            ||
| 699 | *  | 
            ||
| 700 | * @param mixed $string  | 
            ||
| 701 | * @param string $needle  | 
            ||
| 702 | * @param string|null $message  | 
            ||
| 703 | * @param string|null $propertyPath  | 
            ||
| 704 | * @param string $encoding  | 
            ||
| 705 | * @return void  | 
            ||
| 706 | * @throws \Assert\AssertionFailedException  | 
            ||
| 707 | */  | 
            ||
| 708 | public static function startsWith($string, $needle, $message = null, $propertyPath = null, $encoding = 'utf8')  | 
            ||
| 723 | |||
| 724 | /**  | 
            ||
| 725 | * Assert that string ends with a sequence of chars.  | 
            ||
| 726 | *  | 
            ||
| 727 | * @param mixed $string  | 
            ||
| 728 | * @param string $needle  | 
            ||
| 729 | * @param string|null $message  | 
            ||
| 730 | * @param string|null $propertyPath  | 
            ||
| 731 | * @param string $encoding  | 
            ||
| 732 | * @return void  | 
            ||
| 733 | * @throws \Assert\AssertionFailedException  | 
            ||
| 734 | */  | 
            ||
| 735 | public static function endsWith($string, $needle, $message = null, $propertyPath = null, $encoding = 'utf8')  | 
            ||
| 752 | |||
| 753 | /**  | 
            ||
| 754 | * Assert that string contains a sequence of chars.  | 
            ||
| 755 | *  | 
            ||
| 756 | * @param mixed $string  | 
            ||
| 757 | * @param string $needle  | 
            ||
| 758 | * @param string|null $message  | 
            ||
| 759 | * @param string|null $propertyPath  | 
            ||
| 760 | * @param string $encoding  | 
            ||
| 761 | * @return void  | 
            ||
| 762 | * @throws \Assert\AssertionFailedException  | 
            ||
| 763 | */  | 
            ||
| 764 | public static function contains($string, $needle, $message = null, $propertyPath = null, $encoding = 'utf8')  | 
            ||
| 779 | |||
| 780 | /**  | 
            ||
| 781 | * Assert that value is in array of choices.  | 
            ||
| 782 | *  | 
            ||
| 783 | * @param mixed $value  | 
            ||
| 784 | * @param array $choices  | 
            ||
| 785 | * @param string|null $message  | 
            ||
| 786 | * @param string|null $propertyPath  | 
            ||
| 787 | * @return void  | 
            ||
| 788 | * @throws \Assert\AssertionFailedException  | 
            ||
| 789 | */  | 
            ||
| 790 | public static function choice($value, array $choices, $message = null, $propertyPath = null)  | 
            ||
| 802 | |||
| 803 | /**  | 
            ||
| 804 |      * Alias of {@see choice()} | 
            ||
| 805 | *  | 
            ||
| 806 | * @throws \Assert\AssertionFailedException  | 
            ||
| 807 | */  | 
            ||
| 808 | public static function inArray($value, array $choices, $message = null, $propertyPath = null)  | 
            ||
| 812 | |||
| 813 | /**  | 
            ||
| 814 | * Assert that value is numeric.  | 
            ||
| 815 | *  | 
            ||
| 816 | * @param mixed $value  | 
            ||
| 817 | * @param string|null $message  | 
            ||
| 818 | * @param string|null $propertyPath  | 
            ||
| 819 | * @return void  | 
            ||
| 820 | * @throws \Assert\AssertionFailedException  | 
            ||
| 821 | */  | 
            ||
| 822 | public static function numeric($value, $message = null, $propertyPath = null)  | 
            ||
| 833 | |||
| 834 | /**  | 
            ||
| 835 | * Assert that value is an array.  | 
            ||
| 836 | *  | 
            ||
| 837 | * @param mixed $value  | 
            ||
| 838 | * @param string|null $message  | 
            ||
| 839 | * @param string|null $propertyPath  | 
            ||
| 840 | * @return void  | 
            ||
| 841 | * @throws \Assert\AssertionFailedException  | 
            ||
| 842 | */  | 
            ||
| 843 | public static function isArray($value, $message = null, $propertyPath = null)  | 
            ||
| 854 | |||
| 855 | /**  | 
            ||
| 856 | * Assert that value is an array or a traversable object.  | 
            ||
| 857 | *  | 
            ||
| 858 | * @param mixed $value  | 
            ||
| 859 | * @param string|null $message  | 
            ||
| 860 | * @param string|null $propertyPath  | 
            ||
| 861 | * @return void  | 
            ||
| 862 | * @throws \Assert\AssertionFailedException  | 
            ||
| 863 | */  | 
            ||
| 864 | public static function isTraversable($value, $message = null, $propertyPath = null)  | 
            ||
| 875 | |||
| 876 | /**  | 
            ||
| 877 | * Assert that value is an array or an array-accessible object.  | 
            ||
| 878 | *  | 
            ||
| 879 | * @param mixed $value  | 
            ||
| 880 | * @param string|null $message  | 
            ||
| 881 | * @param string|null $propertyPath  | 
            ||
| 882 | * @return void  | 
            ||
| 883 | * @throws \Assert\AssertionFailedException  | 
            ||
| 884 | */  | 
            ||
| 885 | public static function isArrayAccessible($value, $message = null, $propertyPath = null)  | 
            ||
| 896 | |||
| 897 | /**  | 
            ||
| 898 | * Assert that key exists in an array  | 
            ||
| 899 | *  | 
            ||
| 900 | * @param mixed $value  | 
            ||
| 901 | * @param string|integer $key  | 
            ||
| 902 | * @param string|null $message  | 
            ||
| 903 | * @param string|null $propertyPath  | 
            ||
| 904 | * @return void  | 
            ||
| 905 | * @throws \Assert\AssertionFailedException  | 
            ||
| 906 | */  | 
            ||
| 907 | public static function keyExists($value, $key, $message = null, $propertyPath = null)  | 
            ||
| 920 | |||
| 921 | /**  | 
            ||
| 922 | * Assert that key exists in an array/array-accessible object using isset()  | 
            ||
| 923 | *  | 
            ||
| 924 | * @param mixed $value  | 
            ||
| 925 | * @param string|integer $key  | 
            ||
| 926 | * @param string|null $message  | 
            ||
| 927 | * @param string|null $propertyPath  | 
            ||
| 928 | * @return void  | 
            ||
| 929 | * @throws \Assert\AssertionFailedException  | 
            ||
| 930 | */  | 
            ||
| 931 | public static function keyIsset($value, $key, $message = null, $propertyPath = null)  | 
            ||
| 944 | |||
| 945 | /**  | 
            ||
| 946 | * Assert that key exists in an array/array-accessible object and it's value is not empty.  | 
            ||
| 947 | *  | 
            ||
| 948 | * @param mixed $value  | 
            ||
| 949 | * @param string|integer $key  | 
            ||
| 950 | * @param string|null $message  | 
            ||
| 951 | * @param string|null $propertyPath  | 
            ||
| 952 | * @return void  | 
            ||
| 953 | * @throws \Assert\AssertionFailedException  | 
            ||
| 954 | */  | 
            ||
| 955 | public static function notEmptyKey($value, $key, $message = null, $propertyPath = null)  | 
            ||
| 960 | |||
| 961 | /**  | 
            ||
| 962 | * Assert that value is not blank  | 
            ||
| 963 | *  | 
            ||
| 964 | * @param mixed $value  | 
            ||
| 965 | * @param string|null $message  | 
            ||
| 966 | * @param string|null $propertyPath  | 
            ||
| 967 | * @return void  | 
            ||
| 968 | * @throws \Assert\AssertionFailedException  | 
            ||
| 969 | */  | 
            ||
| 970 | public static function notBlank($value, $message = null, $propertyPath = null)  | 
            ||
| 981 | |||
| 982 | /**  | 
            ||
| 983 | * Assert that value is instance of given class-name.  | 
            ||
| 984 | *  | 
            ||
| 985 | * @param mixed $value  | 
            ||
| 986 | * @param string $className  | 
            ||
| 987 | * @param string|null $message  | 
            ||
| 988 | * @param string|null $propertyPath  | 
            ||
| 989 | * @return void  | 
            ||
| 990 | * @throws \Assert\AssertionFailedException  | 
            ||
| 991 | */  | 
            ||
| 992 | public static function isInstanceOf($value, $className, $message = null, $propertyPath = null)  | 
            ||
| 1004 | |||
| 1005 | /**  | 
            ||
| 1006 | * Assert that value is not instance of given class-name.  | 
            ||
| 1007 | *  | 
            ||
| 1008 | * @param mixed $value  | 
            ||
| 1009 | * @param string $className  | 
            ||
| 1010 | * @param string|null $message  | 
            ||
| 1011 | * @param string|null $propertyPath  | 
            ||
| 1012 | * @return void  | 
            ||
| 1013 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1014 | */  | 
            ||
| 1015 | public static function notIsInstanceOf($value, $className, $message = null, $propertyPath = null)  | 
            ||
| 1027 | |||
| 1028 | /**  | 
            ||
| 1029 | * Assert that value is subclass of given class-name.  | 
            ||
| 1030 | *  | 
            ||
| 1031 | * @param mixed $value  | 
            ||
| 1032 | * @param string $className  | 
            ||
| 1033 | * @param string|null $message  | 
            ||
| 1034 | * @param string|null $propertyPath  | 
            ||
| 1035 | * @return void  | 
            ||
| 1036 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1037 | */  | 
            ||
| 1038 | public static function subclassOf($value, $className, $message = null, $propertyPath = null)  | 
            ||
| 1050 | |||
| 1051 | /**  | 
            ||
| 1052 | * Assert that value is in range of numbers.  | 
            ||
| 1053 | *  | 
            ||
| 1054 | * @param mixed $value  | 
            ||
| 1055 | * @param integer $minValue  | 
            ||
| 1056 | * @param integer $maxValue  | 
            ||
| 1057 | * @param string|null $message  | 
            ||
| 1058 | * @param string|null $propertyPath  | 
            ||
| 1059 | * @return void  | 
            ||
| 1060 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1061 | */  | 
            ||
| 1062 | public static function range($value, $minValue, $maxValue, $message = null, $propertyPath = null)  | 
            ||
| 1077 | |||
| 1078 | /**  | 
            ||
| 1079 | * Assert that a value is at least as big as a given limit  | 
            ||
| 1080 | *  | 
            ||
| 1081 | * @param mixed $value  | 
            ||
| 1082 | * @param mixed $minValue  | 
            ||
| 1083 | * @param string|null $message  | 
            ||
| 1084 | * @param string|null $propertyPath  | 
            ||
| 1085 | * @return void  | 
            ||
| 1086 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1087 | */  | 
            ||
| 1088 | public static function min($value, $minValue, $message = null, $propertyPath = null)  | 
            ||
| 1102 | |||
| 1103 | /**  | 
            ||
| 1104 | * Assert that a number is smaller as a given limit  | 
            ||
| 1105 | *  | 
            ||
| 1106 | * @param mixed $value  | 
            ||
| 1107 | * @param mixed $maxValue  | 
            ||
| 1108 | * @param string|null $message  | 
            ||
| 1109 | * @param string|null $propertyPath  | 
            ||
| 1110 | * @return void  | 
            ||
| 1111 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1112 | */  | 
            ||
| 1113 | public static function max($value, $maxValue, $message = null, $propertyPath = null)  | 
            ||
| 1127 | |||
| 1128 | /**  | 
            ||
| 1129 | * Assert that a file exists  | 
            ||
| 1130 | *  | 
            ||
| 1131 | * @param string $value  | 
            ||
| 1132 | * @param string|null $message  | 
            ||
| 1133 | * @param string|null $propertyPath  | 
            ||
| 1134 | * @return void  | 
            ||
| 1135 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1136 | */  | 
            ||
| 1137 | public static function file($value, $message = null, $propertyPath = null)  | 
            ||
| 1151 | |||
| 1152 | /**  | 
            ||
| 1153 | * Assert that a directory exists  | 
            ||
| 1154 | *  | 
            ||
| 1155 | * @param string $value  | 
            ||
| 1156 | * @param string|null $message  | 
            ||
| 1157 | * @param string|null $propertyPath  | 
            ||
| 1158 | * @return void  | 
            ||
| 1159 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1160 | */  | 
            ||
| 1161 | public static function directory($value, $message = null, $propertyPath = null)  | 
            ||
| 1174 | |||
| 1175 | /**  | 
            ||
| 1176 | * Assert that the value is something readable  | 
            ||
| 1177 | *  | 
            ||
| 1178 | * @param string $value  | 
            ||
| 1179 | * @param string|null $message  | 
            ||
| 1180 | * @param string|null $propertyPath  | 
            ||
| 1181 | * @return void  | 
            ||
| 1182 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1183 | */  | 
            ||
| 1184 | public static function readable($value, $message = null, $propertyPath = null)  | 
            ||
| 1197 | |||
| 1198 | /**  | 
            ||
| 1199 | * Assert that the value is something writeable  | 
            ||
| 1200 | *  | 
            ||
| 1201 | * @param string $value  | 
            ||
| 1202 | * @param string|null $message  | 
            ||
| 1203 | * @param string|null $propertyPath  | 
            ||
| 1204 | * @return void  | 
            ||
| 1205 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1206 | */  | 
            ||
| 1207 | public static function writeable($value, $message = null, $propertyPath = null)  | 
            ||
| 1220 | |||
| 1221 | /**  | 
            ||
| 1222 | * Assert that value is an email adress (using input_filter/FILTER_VALIDATE_EMAIL).  | 
            ||
| 1223 | *  | 
            ||
| 1224 | * @param mixed $value  | 
            ||
| 1225 | * @param string|null $message  | 
            ||
| 1226 | * @param string|null $propertyPath  | 
            ||
| 1227 | * @return void  | 
            ||
| 1228 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1229 | */  | 
            ||
| 1230 | public static function email($value, $message = null, $propertyPath = null)  | 
            ||
| 1255 | |||
| 1256 | /**  | 
            ||
| 1257 | * Assert that value is an URL.  | 
            ||
| 1258 | *  | 
            ||
| 1259 | * This code snipped was taken from the Symfony project and modified to the special demands of this method.  | 
            ||
| 1260 | *  | 
            ||
| 1261 | * @param mixed $value  | 
            ||
| 1262 | * @param string|null $message  | 
            ||
| 1263 | * @param string|null $propertyPath  | 
            ||
| 1264 | * @return void  | 
            ||
| 1265 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1266 | *  | 
            ||
| 1267 | *  | 
            ||
| 1268 | * @link https://github.com/symfony/Validator/blob/master/Constraints/UrlValidator.php  | 
            ||
| 1269 | * @link https://github.com/symfony/Validator/blob/master/Constraints/Url.php  | 
            ||
| 1270 | */  | 
            ||
| 1271 | public static function url($value, $message = null, $propertyPath = null)  | 
            ||
| 1304 | |||
| 1305 | /**  | 
            ||
| 1306 | * Assert that value is alphanumeric.  | 
            ||
| 1307 | *  | 
            ||
| 1308 | * @param mixed $value  | 
            ||
| 1309 | * @param string|null $message  | 
            ||
| 1310 | * @param string|null $propertyPath  | 
            ||
| 1311 | * @return void  | 
            ||
| 1312 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1313 | */  | 
            ||
| 1314 | public static function alnum($value, $message = null, $propertyPath = null)  | 
            ||
| 1327 | |||
| 1328 | /**  | 
            ||
| 1329 | * Assert that the value is boolean True.  | 
            ||
| 1330 | *  | 
            ||
| 1331 | * @param mixed $value  | 
            ||
| 1332 | * @param string|null $message  | 
            ||
| 1333 | * @param string|null $propertyPath  | 
            ||
| 1334 | * @return void  | 
            ||
| 1335 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1336 | */  | 
            ||
| 1337 | public static function true($value, $message = null, $propertyPath = null)  | 
            ||
| 1348 | |||
| 1349 | /**  | 
            ||
| 1350 | * Assert that the value is boolean False.  | 
            ||
| 1351 | *  | 
            ||
| 1352 | * @param mixed $value  | 
            ||
| 1353 | * @param string|null $message  | 
            ||
| 1354 | * @param string|null $propertyPath  | 
            ||
| 1355 | * @return void  | 
            ||
| 1356 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1357 | */  | 
            ||
| 1358 | public static function false($value, $message = null, $propertyPath = null)  | 
            ||
| 1369 | |||
| 1370 | /**  | 
            ||
| 1371 | * Assert that the class exists.  | 
            ||
| 1372 | *  | 
            ||
| 1373 | * @param mixed $value  | 
            ||
| 1374 | * @param string|null $message  | 
            ||
| 1375 | * @param string|null $propertyPath  | 
            ||
| 1376 | * @return void  | 
            ||
| 1377 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1378 | */  | 
            ||
| 1379 | public static function classExists($value, $message = null, $propertyPath = null)  | 
            ||
| 1390 | |||
| 1391 | /**  | 
            ||
| 1392 | * Assert that the class implements the interface  | 
            ||
| 1393 | *  | 
            ||
| 1394 | * @param mixed $class  | 
            ||
| 1395 | * @param string $interfaceName  | 
            ||
| 1396 | * @param string|null $message  | 
            ||
| 1397 | * @param string|null $propertyPath  | 
            ||
| 1398 | * @return void  | 
            ||
| 1399 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1400 | */  | 
            ||
| 1401 | public static function implementsInterface($class, $interfaceName, $message = null, $propertyPath = null)  | 
            ||
| 1414 | |||
| 1415 | /**  | 
            ||
| 1416 | * Assert that the given string is a valid json string.  | 
            ||
| 1417 | *  | 
            ||
| 1418 | * NOTICE:  | 
            ||
| 1419 | * Since this does a json_decode to determine its validity  | 
            ||
| 1420 | * you probably should consider, when using the variable  | 
            ||
| 1421 | * content afterwards, just to decode and check for yourself instead  | 
            ||
| 1422 | * of using this assertion.  | 
            ||
| 1423 | *  | 
            ||
| 1424 | * @param mixed $value  | 
            ||
| 1425 | * @param string|null $message  | 
            ||
| 1426 | * @param string|null $propertyPath  | 
            ||
| 1427 | * @return void  | 
            ||
| 1428 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1429 | */  | 
            ||
| 1430 | public static function isJsonString($value, $message = null, $propertyPath = null)  | 
            ||
| 1441 | |||
| 1442 | /**  | 
            ||
| 1443 | * Assert that the given string is a valid UUID  | 
            ||
| 1444 | *  | 
            ||
| 1445 |      * Uses code from {@link https://github.com/ramsey/uuid} that is MIT licensed. | 
            ||
| 1446 | *  | 
            ||
| 1447 | * @param string $value  | 
            ||
| 1448 | * @param string|null $message  | 
            ||
| 1449 | * @param string|null $propertyPath  | 
            ||
| 1450 | * @return void  | 
            ||
| 1451 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1452 | */  | 
            ||
| 1453 | public static function uuid($value, $message = null, $propertyPath = null)  | 
            ||
| 1470 | |||
| 1471 | /**  | 
            ||
| 1472 | * Assert that the count of countable is equal to count.  | 
            ||
| 1473 | *  | 
            ||
| 1474 | * @param array|\Countable $countable  | 
            ||
| 1475 | * @param int $count  | 
            ||
| 1476 | * @param string $message  | 
            ||
| 1477 | * @param string $propertyPath  | 
            ||
| 1478 | * @return void  | 
            ||
| 1479 | * @throws \Assert\AssertionFailedException  | 
            ||
| 1480 | */  | 
            ||
| 1481 | public static function count($countable, $count, $message = null, $propertyPath = null)  | 
            ||
| 1492 | |||
| 1493 | /**  | 
            ||
| 1494 | * static call handler to implement:  | 
            ||
| 1495 | * - "null or assertion" delegation  | 
            ||
| 1496 | * - "all" delegation  | 
            ||
| 1497 | */  | 
            ||
| 1498 | public static function __callStatic($method, $args)  | 
            ||
| 1534 | |||
| 1535 | /**  | 
            ||
| 1536 | * Determines if the values array has every choice as key and that this choice has content.  | 
            ||
| 1537 | *  | 
            ||
| 1538 | * @param array $values  | 
            ||
| 1539 | * @param array $choices  | 
            ||
| 1540 | * @param null $message  | 
            ||
| 1541 | * @param null $propertyPath  | 
            ||
| 1542 | */  | 
            ||
| 1543 | public static function choicesNotEmpty(array $values, array $choices, $message = null, $propertyPath = null)  | 
            ||
| 1552 | |||
| 1553 | /**  | 
            ||
| 1554 | * Determines that the named method is defined in the provided object.  | 
            ||
| 1555 | *  | 
            ||
| 1556 | * @param string $value  | 
            ||
| 1557 | * @param mixed $object  | 
            ||
| 1558 | * @param null $message  | 
            ||
| 1559 | * @param null $propertyPath  | 
            ||
| 1560 | *  | 
            ||
| 1561 | * @throws  | 
            ||
| 1562 | */  | 
            ||
| 1563 | public static function methodExists($value, $object, $message = null, $propertyPath = null)  | 
            ||
| 1576 | |||
| 1577 | /**  | 
            ||
| 1578 | * Determines that the provided value is an object.  | 
            ||
| 1579 | *  | 
            ||
| 1580 | * @param mixed $value  | 
            ||
| 1581 | * @param null $message  | 
            ||
| 1582 | * @param null $propertyPath  | 
            ||
| 1583 | */  | 
            ||
| 1584 | public static function isObject($value, $message = null, $propertyPath = null)  | 
            ||
| 1596 | |||
| 1597 | /**  | 
            ||
| 1598 | * Determines if the value is less than given limit.  | 
            ||
| 1599 | *  | 
            ||
| 1600 | * @param mixed $value  | 
            ||
| 1601 | * @param mixed $limit  | 
            ||
| 1602 | * @param null $message  | 
            ||
| 1603 | * @param null $propertyPath  | 
            ||
| 1604 | */  | 
            ||
| 1605 | public static function lessThan($value, $limit, $message = null, $propertyPath = null)  | 
            ||
| 1617 | |||
| 1618 | /**  | 
            ||
| 1619 | * Determines if the value is less or than given limit.  | 
            ||
| 1620 | *  | 
            ||
| 1621 | * @param mixed $value  | 
            ||
| 1622 | * @param mixed $limit  | 
            ||
| 1623 | * @param null $message  | 
            ||
| 1624 | * @param null $propertyPath  | 
            ||
| 1625 | */  | 
            ||
| 1626 | public static function lessOrEqualThan($value, $limit, $message = null, $propertyPath = null)  | 
            ||
| 1638 | |||
| 1639 | /**  | 
            ||
| 1640 | * Determines if the value is greater than given limit.  | 
            ||
| 1641 | *  | 
            ||
| 1642 | * @param mixed $value  | 
            ||
| 1643 | * @param mixed $limit  | 
            ||
| 1644 | * @param null $message  | 
            ||
| 1645 | * @param null $propertyPath  | 
            ||
| 1646 | */  | 
            ||
| 1647 | public static function greaterThan($value, $limit, $message = null, $propertyPath = null)  | 
            ||
| 1659 | |||
| 1660 | /**  | 
            ||
| 1661 | * Determines if the value is greater or equal than given limit.  | 
            ||
| 1662 | *  | 
            ||
| 1663 | * @param mixed $value  | 
            ||
| 1664 | * @param mixed $limit  | 
            ||
| 1665 | * @param null $message  | 
            ||
| 1666 | * @param null $propertyPath  | 
            ||
| 1667 | */  | 
            ||
| 1668 | public static function greaterOrEqualThan($value, $limit, $message = null, $propertyPath = null)  | 
            ||
| 1680 | |||
| 1681 | /**  | 
            ||
| 1682 | * Assert that date is valid and corresponds to the given format.  | 
            ||
| 1683 | *  | 
            ||
| 1684 | * @param string $value  | 
            ||
| 1685 | * @param string $format supports all of the options date(), except for the following:  | 
            ||
| 1686 | * N, w, W, t, L, o, B, a, A, g, h, I, O, P, Z, c, r.  | 
            ||
| 1687 | * @param string|null $message  | 
            ||
| 1688 | * @param string|null $propertyPath  | 
            ||
| 1689 | *  | 
            ||
| 1690 | * @link http://php.net/manual/function.date.php#refsect1-function.date-parameters  | 
            ||
| 1691 | */  | 
            ||
| 1692 | public static function date($value, $format, $message = null, $propertyPath = null)  | 
            ||
| 1709 | |||
| 1710 | /**  | 
            ||
| 1711 | * Determines that the provided value is callable.  | 
            ||
| 1712 | *  | 
            ||
| 1713 | * @param mixed $value  | 
            ||
| 1714 | * @param null $message  | 
            ||
| 1715 | * @param null $propertyPath  | 
            ||
| 1716 | */  | 
            ||
| 1717 | public static function isCallable($value, $message = null, $propertyPath = null)  | 
            ||
| 1728 | |||
| 1729 | /**  | 
            ||
| 1730 | * Make a string version of a value.  | 
            ||
| 1731 | *  | 
            ||
| 1732 | * @param mixed $value  | 
            ||
| 1733 | * @return string  | 
            ||
| 1734 | */  | 
            ||
| 1735 | protected static function stringify($value)  | 
            ||
| 1769 | }  | 
            ||
| 1770 | |||
| 1771 |