| @@ 806-814 (lines=9) @@ | ||
| 803 | } |
|
| 804 | } |
|
| 805 | ||
| 806 | public static function keyExists($array, $key, $message = '') |
|
| 807 | { |
|
| 808 | if (!array_key_exists($key, $array)) { |
|
| 809 | static::reportInvalidArgument(sprintf( |
|
| 810 | $message ?: 'Expected the key %s to exist.', |
|
| 811 | static::valueToString($key) |
|
| 812 | )); |
|
| 813 | } |
|
| 814 | } |
|
| 815 | ||
| 816 | public static function keyNotExists($array, $key, $message = '') |
|
| 817 | { |
|
| @@ 816-824 (lines=9) @@ | ||
| 813 | } |
|
| 814 | } |
|
| 815 | ||
| 816 | public static function keyNotExists($array, $key, $message = '') |
|
| 817 | { |
|
| 818 | if (array_key_exists($key, $array)) { |
|
| 819 | static::reportInvalidArgument(sprintf( |
|
| 820 | $message ?: 'Expected the key %s to not exist.', |
|
| 821 | static::valueToString($key) |
|
| 822 | )); |
|
| 823 | } |
|
| 824 | } |
|
| 825 | ||
| 826 | public static function count($array, $number, $message = '') |
|
| 827 | { |
|
| @@ 835-844 (lines=10) @@ | ||
| 832 | ); |
|
| 833 | } |
|
| 834 | ||
| 835 | public static function minCount($array, $min, $message = '') |
|
| 836 | { |
|
| 837 | if (count($array) < $min) { |
|
| 838 | static::reportInvalidArgument(sprintf( |
|
| 839 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 840 | count($array), |
|
| 841 | $min |
|
| 842 | )); |
|
| 843 | } |
|
| 844 | } |
|
| 845 | ||
| 846 | public static function maxCount($array, $max, $message = '') |
|
| 847 | { |
|
| @@ 846-855 (lines=10) @@ | ||
| 843 | } |
|
| 844 | } |
|
| 845 | ||
| 846 | public static function maxCount($array, $max, $message = '') |
|
| 847 | { |
|
| 848 | if (count($array) > $max) { |
|
| 849 | static::reportInvalidArgument(sprintf( |
|
| 850 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 851 | count($array), |
|
| 852 | $max |
|
| 853 | )); |
|
| 854 | } |
|
| 855 | } |
|
| 856 | ||
| 857 | public static function countBetween($array, $min, $max, $message = '') |
|
| 858 | { |
|