| @@ 846-854 (lines=9) @@ | ||
| 843 | } |
|
| 844 | } |
|
| 845 | ||
| 846 | public static function keyExists($array, $key, $message = '') |
|
| 847 | { |
|
| 848 | if (!array_key_exists($key, $array)) { |
|
| 849 | static::reportInvalidArgument(sprintf( |
|
| 850 | $message ?: 'Expected the key %s to exist.', |
|
| 851 | static::valueToString($key) |
|
| 852 | )); |
|
| 853 | } |
|
| 854 | } |
|
| 855 | ||
| 856 | public static function keyNotExists($array, $key, $message = '') |
|
| 857 | { |
|
| @@ 856-864 (lines=9) @@ | ||
| 853 | } |
|
| 854 | } |
|
| 855 | ||
| 856 | public static function keyNotExists($array, $key, $message = '') |
|
| 857 | { |
|
| 858 | if (array_key_exists($key, $array)) { |
|
| 859 | static::reportInvalidArgument(sprintf( |
|
| 860 | $message ?: 'Expected the key %s to not exist.', |
|
| 861 | static::valueToString($key) |
|
| 862 | )); |
|
| 863 | } |
|
| 864 | } |
|
| 865 | ||
| 866 | public static function count($array, $number, $message = '') |
|
| 867 | { |
|
| @@ 875-884 (lines=10) @@ | ||
| 872 | ); |
|
| 873 | } |
|
| 874 | ||
| 875 | public static function minCount($array, $min, $message = '') |
|
| 876 | { |
|
| 877 | if (count($array) < $min) { |
|
| 878 | static::reportInvalidArgument(sprintf( |
|
| 879 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 880 | count($array), |
|
| 881 | $min |
|
| 882 | )); |
|
| 883 | } |
|
| 884 | } |
|
| 885 | ||
| 886 | public static function maxCount($array, $max, $message = '') |
|
| 887 | { |
|
| @@ 886-895 (lines=10) @@ | ||
| 883 | } |
|
| 884 | } |
|
| 885 | ||
| 886 | public static function maxCount($array, $max, $message = '') |
|
| 887 | { |
|
| 888 | if (count($array) > $max) { |
|
| 889 | static::reportInvalidArgument(sprintf( |
|
| 890 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 891 | count($array), |
|
| 892 | $max |
|
| 893 | )); |
|
| 894 | } |
|
| 895 | } |
|
| 896 | ||
| 897 | public static function countBetween($array, $min, $max, $message = '') |
|
| 898 | { |
|