| @@ 824-832 (lines=9) @@ | ||
| 821 | } |
|
| 822 | } |
|
| 823 | ||
| 824 | public static function keyExists($array, $key, $message = '') |
|
| 825 | { |
|
| 826 | if (!array_key_exists($key, $array)) { |
|
| 827 | static::reportInvalidArgument(sprintf( |
|
| 828 | $message ?: 'Expected the key %s to exist.', |
|
| 829 | static::valueToString($key) |
|
| 830 | )); |
|
| 831 | } |
|
| 832 | } |
|
| 833 | ||
| 834 | public static function keyNotExists($array, $key, $message = '') |
|
| 835 | { |
|
| @@ 834-842 (lines=9) @@ | ||
| 831 | } |
|
| 832 | } |
|
| 833 | ||
| 834 | public static function keyNotExists($array, $key, $message = '') |
|
| 835 | { |
|
| 836 | if (array_key_exists($key, $array)) { |
|
| 837 | static::reportInvalidArgument(sprintf( |
|
| 838 | $message ?: 'Expected the key %s to not exist.', |
|
| 839 | static::valueToString($key) |
|
| 840 | )); |
|
| 841 | } |
|
| 842 | } |
|
| 843 | ||
| 844 | public static function count($array, $number, $message = '') |
|
| 845 | { |
|
| @@ 853-862 (lines=10) @@ | ||
| 850 | ); |
|
| 851 | } |
|
| 852 | ||
| 853 | public static function minCount($array, $min, $message = '') |
|
| 854 | { |
|
| 855 | if (count($array) < $min) { |
|
| 856 | static::reportInvalidArgument(sprintf( |
|
| 857 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 858 | count($array), |
|
| 859 | $min |
|
| 860 | )); |
|
| 861 | } |
|
| 862 | } |
|
| 863 | ||
| 864 | public static function maxCount($array, $max, $message = '') |
|
| 865 | { |
|
| @@ 864-873 (lines=10) @@ | ||
| 861 | } |
|
| 862 | } |
|
| 863 | ||
| 864 | public static function maxCount($array, $max, $message = '') |
|
| 865 | { |
|
| 866 | if (count($array) > $max) { |
|
| 867 | static::reportInvalidArgument(sprintf( |
|
| 868 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 869 | count($array), |
|
| 870 | $max |
|
| 871 | )); |
|
| 872 | } |
|
| 873 | } |
|
| 874 | ||
| 875 | public static function countBetween($array, $min, $max, $message = '') |
|
| 876 | { |
|