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