| @@ 872-880 (lines=9) @@ | ||
| 869 | } |
|
| 870 | } |
|
| 871 | ||
| 872 | public static function keyExists($array, $key, $message = '') |
|
| 873 | { |
|
| 874 | if (!array_key_exists($key, $array)) { |
|
| 875 | static::reportInvalidArgument(sprintf( |
|
| 876 | $message ?: 'Expected the key %s to exist.', |
|
| 877 | static::valueToString($key) |
|
| 878 | )); |
|
| 879 | } |
|
| 880 | } |
|
| 881 | ||
| 882 | public static function keyNotExists($array, $key, $message = '') |
|
| 883 | { |
|
| @@ 882-890 (lines=9) @@ | ||
| 879 | } |
|
| 880 | } |
|
| 881 | ||
| 882 | public static function keyNotExists($array, $key, $message = '') |
|
| 883 | { |
|
| 884 | if (array_key_exists($key, $array)) { |
|
| 885 | static::reportInvalidArgument(sprintf( |
|
| 886 | $message ?: 'Expected the key %s to not exist.', |
|
| 887 | static::valueToString($key) |
|
| 888 | )); |
|
| 889 | } |
|
| 890 | } |
|
| 891 | ||
| 892 | public static function count($array, $number, $message = '') |
|
| 893 | { |
|
| @@ 901-910 (lines=10) @@ | ||
| 898 | ); |
|
| 899 | } |
|
| 900 | ||
| 901 | public static function minCount($array, $min, $message = '') |
|
| 902 | { |
|
| 903 | if (count($array) < $min) { |
|
| 904 | static::reportInvalidArgument(sprintf( |
|
| 905 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 906 | count($array), |
|
| 907 | $min |
|
| 908 | )); |
|
| 909 | } |
|
| 910 | } |
|
| 911 | ||
| 912 | public static function maxCount($array, $max, $message = '') |
|
| 913 | { |
|
| @@ 912-921 (lines=10) @@ | ||
| 909 | } |
|
| 910 | } |
|
| 911 | ||
| 912 | public static function maxCount($array, $max, $message = '') |
|
| 913 | { |
|
| 914 | if (count($array) > $max) { |
|
| 915 | static::reportInvalidArgument(sprintf( |
|
| 916 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 917 | count($array), |
|
| 918 | $max |
|
| 919 | )); |
|
| 920 | } |
|
| 921 | } |
|
| 922 | ||
| 923 | public static function countBetween($array, $min, $max, $message = '') |
|
| 924 | { |
|