@@ 836-844 (lines=9) @@ | ||
833 | } |
|
834 | } |
|
835 | ||
836 | public static function keyExists($array, $key, $message = '') |
|
837 | { |
|
838 | if (!array_key_exists($key, $array)) { |
|
839 | static::reportInvalidArgument(sprintf( |
|
840 | $message ?: 'Expected the key %s to exist.', |
|
841 | static::valueToString($key) |
|
842 | )); |
|
843 | } |
|
844 | } |
|
845 | ||
846 | public static function keyNotExists($array, $key, $message = '') |
|
847 | { |
|
@@ 846-854 (lines=9) @@ | ||
843 | } |
|
844 | } |
|
845 | ||
846 | public static function keyNotExists($array, $key, $message = '') |
|
847 | { |
|
848 | if (array_key_exists($key, $array)) { |
|
849 | static::reportInvalidArgument(sprintf( |
|
850 | $message ?: 'Expected the key %s to not exist.', |
|
851 | static::valueToString($key) |
|
852 | )); |
|
853 | } |
|
854 | } |
|
855 | ||
856 | public static function count($array, $number, $message = '') |
|
857 | { |
|
@@ 865-874 (lines=10) @@ | ||
862 | ); |
|
863 | } |
|
864 | ||
865 | public static function minCount($array, $min, $message = '') |
|
866 | { |
|
867 | if (count($array) < $min) { |
|
868 | static::reportInvalidArgument(sprintf( |
|
869 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
870 | count($array), |
|
871 | $min |
|
872 | )); |
|
873 | } |
|
874 | } |
|
875 | ||
876 | public static function maxCount($array, $max, $message = '') |
|
877 | { |
|
@@ 876-885 (lines=10) @@ | ||
873 | } |
|
874 | } |
|
875 | ||
876 | public static function maxCount($array, $max, $message = '') |
|
877 | { |
|
878 | if (count($array) > $max) { |
|
879 | static::reportInvalidArgument(sprintf( |
|
880 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
881 | count($array), |
|
882 | $max |
|
883 | )); |
|
884 | } |
|
885 | } |
|
886 | ||
887 | public static function countBetween($array, $min, $max, $message = '') |
|
888 | { |