| @@ 902-910 (lines=9) @@ | ||
| 899 | } |
|
| 900 | } |
|
| 901 | ||
| 902 | public static function keyExists($array, $key, $message = '') |
|
| 903 | { |
|
| 904 | if (!array_key_exists($key, $array)) { |
|
| 905 | static::reportInvalidArgument(sprintf( |
|
| 906 | $message ?: 'Expected the key %s to exist.', |
|
| 907 | static::valueToString($key) |
|
| 908 | )); |
|
| 909 | } |
|
| 910 | } |
|
| 911 | ||
| 912 | public static function keyNotExists($array, $key, $message = '') |
|
| 913 | { |
|
| @@ 912-920 (lines=9) @@ | ||
| 909 | } |
|
| 910 | } |
|
| 911 | ||
| 912 | public static function keyNotExists($array, $key, $message = '') |
|
| 913 | { |
|
| 914 | if (array_key_exists($key, $array)) { |
|
| 915 | static::reportInvalidArgument(sprintf( |
|
| 916 | $message ?: 'Expected the key %s to not exist.', |
|
| 917 | static::valueToString($key) |
|
| 918 | )); |
|
| 919 | } |
|
| 920 | } |
|
| 921 | ||
| 922 | public static function count($array, $number, $message = '') |
|
| 923 | { |
|
| @@ 931-940 (lines=10) @@ | ||
| 928 | ); |
|
| 929 | } |
|
| 930 | ||
| 931 | public static function minCount($array, $min, $message = '') |
|
| 932 | { |
|
| 933 | if (count($array) < $min) { |
|
| 934 | static::reportInvalidArgument(sprintf( |
|
| 935 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 936 | count($array), |
|
| 937 | $min |
|
| 938 | )); |
|
| 939 | } |
|
| 940 | } |
|
| 941 | ||
| 942 | public static function maxCount($array, $max, $message = '') |
|
| 943 | { |
|
| @@ 942-951 (lines=10) @@ | ||
| 939 | } |
|
| 940 | } |
|
| 941 | ||
| 942 | public static function maxCount($array, $max, $message = '') |
|
| 943 | { |
|
| 944 | if (count($array) > $max) { |
|
| 945 | static::reportInvalidArgument(sprintf( |
|
| 946 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 947 | count($array), |
|
| 948 | $max |
|
| 949 | )); |
|
| 950 | } |
|
| 951 | } |
|
| 952 | ||
| 953 | public static function countBetween($array, $min, $max, $message = '') |
|
| 954 | { |
|