ArrayUtils

Utilities to perform common array operations

package

Default

Methods

Strictly check that the provided value is a non empty array or throw an exception

forceNonEmptyArray(mixed $value,string $valueName = '',string $errorMessage = 'must be a non empty array'): void
static
Throws
\InvalidArgumentException

If the check fails

Arguments

$value

mixed

A value to check

$valueName

string

The name of the value to be shown at the beginning of the exception message

$errorMessage

string

The rest of the exception message

Get all the duplicate values on the provided array Duplicate values with different data types won't be considered as equal ('1', 1 will return false)

getDuplicateElements(array $array): array
static
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$array

array

An array containing some elements to test

Response

array

list with all the elements that are duplicated on the provided array

Check if the given array contains duplicate values or not.

hasDuplicateElements(array $array): boolean
static

Duplicate values with different data types won't be considered as equal ('1', 1 will return false)

Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$array

array

An array containing some elements to test

Response

boolean

True if there are duplicate values, false otherwise

Tells if the given value is an array or not

isArray(mixed $value): boolean
static
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$value

mixed

A value to check

Response

boolean

true if the given value is an array, false otherwise

Check if two provided arrays are identical (have exactly the same elements and in the same order).

isEqualTo(array $array1,array $array2): boolean
static
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$array1

array

First array to compare

$array2

array

Second array to compare

Response

boolean

true if arrays are exactly the same, false if not

isStringFound

isStringFound()
static
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

remove all the duplicate values on the provided array Duplicate values with different data types won't be considered as equal ('1', 1 will not be removed)

removeDuplicateElements(array $array): array
static
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$array

array

An array with possible duplicate values

Response

array

The same provided array but without duplicate elements

Remove the specified item from an array

removeElement(array $array,mixed $element)
static
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
returns

array The provided array but without the specified element (if found). Note that originally received array is not modified by this method

Arguments

$array

array

An array (it will not be modified by this method)

$element

mixed

The element that must be removed from the given array