| @@ 891-899 (lines=9) @@ | ||
| 888 | } |
|
| 889 | } |
|
| 890 | ||
| 891 | public static function keyExists($array, $key, $message = '') |
|
| 892 | { |
|
| 893 | if (!array_key_exists($key, $array)) { |
|
| 894 | static::reportInvalidArgument(sprintf( |
|
| 895 | $message ?: 'Expected the key %s to exist.', |
|
| 896 | static::valueToString($key) |
|
| 897 | )); |
|
| 898 | } |
|
| 899 | } |
|
| 900 | ||
| 901 | public static function keyNotExists($array, $key, $message = '') |
|
| 902 | { |
|
| @@ 901-909 (lines=9) @@ | ||
| 898 | } |
|
| 899 | } |
|
| 900 | ||
| 901 | public static function keyNotExists($array, $key, $message = '') |
|
| 902 | { |
|
| 903 | if (array_key_exists($key, $array)) { |
|
| 904 | static::reportInvalidArgument(sprintf( |
|
| 905 | $message ?: 'Expected the key %s to not exist.', |
|
| 906 | static::valueToString($key) |
|
| 907 | )); |
|
| 908 | } |
|
| 909 | } |
|
| 910 | ||
| 911 | public static function count($array, $number, $message = '') |
|
| 912 | { |
|
| @@ 920-929 (lines=10) @@ | ||
| 917 | ); |
|
| 918 | } |
|
| 919 | ||
| 920 | public static function minCount($array, $min, $message = '') |
|
| 921 | { |
|
| 922 | if (count($array) < $min) { |
|
| 923 | static::reportInvalidArgument(sprintf( |
|
| 924 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 925 | count($array), |
|
| 926 | $min |
|
| 927 | )); |
|
| 928 | } |
|
| 929 | } |
|
| 930 | ||
| 931 | public static function maxCount($array, $max, $message = '') |
|
| 932 | { |
|
| @@ 931-940 (lines=10) @@ | ||
| 928 | } |
|
| 929 | } |
|
| 930 | ||
| 931 | public static function maxCount($array, $max, $message = '') |
|
| 932 | { |
|
| 933 | if (count($array) > $max) { |
|
| 934 | static::reportInvalidArgument(sprintf( |
|
| 935 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 936 | count($array), |
|
| 937 | $max |
|
| 938 | )); |
|
| 939 | } |
|
| 940 | } |
|
| 941 | ||
| 942 | public static function countBetween($array, $min, $max, $message = '') |
|
| 943 | { |
|