| @@ 859-867 (lines=9) @@ | ||
| 856 | } |
|
| 857 | } |
|
| 858 | ||
| 859 | public static function keyExists($array, $key, $message = '') |
|
| 860 | { |
|
| 861 | if (!array_key_exists($key, $array)) { |
|
| 862 | static::reportInvalidArgument(sprintf( |
|
| 863 | $message ?: 'Expected the key %s to exist.', |
|
| 864 | static::valueToString($key) |
|
| 865 | )); |
|
| 866 | } |
|
| 867 | } |
|
| 868 | ||
| 869 | public static function keyNotExists($array, $key, $message = '') |
|
| 870 | { |
|
| @@ 869-877 (lines=9) @@ | ||
| 866 | } |
|
| 867 | } |
|
| 868 | ||
| 869 | public static function keyNotExists($array, $key, $message = '') |
|
| 870 | { |
|
| 871 | if (array_key_exists($key, $array)) { |
|
| 872 | static::reportInvalidArgument(sprintf( |
|
| 873 | $message ?: 'Expected the key %s to not exist.', |
|
| 874 | static::valueToString($key) |
|
| 875 | )); |
|
| 876 | } |
|
| 877 | } |
|
| 878 | ||
| 879 | public static function count($array, $number, $message = '') |
|
| 880 | { |
|
| @@ 888-897 (lines=10) @@ | ||
| 885 | ); |
|
| 886 | } |
|
| 887 | ||
| 888 | public static function minCount($array, $min, $message = '') |
|
| 889 | { |
|
| 890 | if (count($array) < $min) { |
|
| 891 | static::reportInvalidArgument(sprintf( |
|
| 892 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 893 | count($array), |
|
| 894 | $min |
|
| 895 | )); |
|
| 896 | } |
|
| 897 | } |
|
| 898 | ||
| 899 | public static function maxCount($array, $max, $message = '') |
|
| 900 | { |
|
| @@ 899-908 (lines=10) @@ | ||
| 896 | } |
|
| 897 | } |
|
| 898 | ||
| 899 | public static function maxCount($array, $max, $message = '') |
|
| 900 | { |
|
| 901 | if (count($array) > $max) { |
|
| 902 | static::reportInvalidArgument(sprintf( |
|
| 903 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 904 | count($array), |
|
| 905 | $max |
|
| 906 | )); |
|
| 907 | } |
|
| 908 | } |
|
| 909 | ||
| 910 | public static function countBetween($array, $min, $max, $message = '') |
|
| 911 | { |
|