Utilities to perform common array operations
| package | Default |
|---|
forceNonEmptyArray(mixed $value,string $valueName = '',string $errorMessage = 'must be a non empty array'): void
| Throws |
|
|---|
mixedA value to check
stringThe name of the value to be shown at the beginning of the exception message
stringThe rest of the exception message
getDuplicateElements(array $array): array
arrayAn array containing some elements to test
arraylist with all the elements that are duplicated on the provided array
hasDuplicateElements(array $array): boolean
Duplicate values with different data types won't be considered as equal ('1', 1 will return false)
arrayAn array containing some elements to test
booleanTrue if there are duplicate values, false otherwise
isArray(mixed $value): boolean
mixedA value to check
booleantrue if the given value is an array, false otherwise
isEqualTo(array $array1,array $array2): boolean
arrayFirst array to compare
arraySecond array to compare
booleantrue if arrays are exactly the same, false if not
isStringFound()
removeDuplicateElements(array $array): array
arrayAn array with possible duplicate values
arrayThe same provided array but without duplicate elements
removeElement(array $array,mixed $element)
| returns | array The provided array but without the specified element (if found). Note that originally received array is not modified by this method |
|---|---|
arrayAn array (it will not be modified by this method)
mixedThe element that must be removed from the given array