public static function ArrayConfig::isMergable in Little helpers 7.2
Check whether an array is mergable.
Parameters
array $value: The array to check.
Return value
bool TRUE if the array is mergable, otherwise FALSE.
5 calls to ArrayConfig::isMergable()
- ArrayConfig::mergeDefaults in src/
ArrayConfig.php - Helper functions that recursively merges $defaults into a $config array.
- ArrayConfigTest::testMergableAssociativaArray in tests/
ArrayConfigTest.php - Test simple associatve arrays are mergable.
- ArrayConfigTest::testMergableCheckboxValues in tests/
ArrayConfigTest.php - Test that arrays that look like checkbox values are not mergable.
- ArrayConfigTest::testMergableMixedArray in tests/
ArrayConfigTest.php - Test that mixed arrays are mergable.
- ArrayConfigTest::testMergableNumericArray in tests/
ArrayConfigTest.php - Test that numeric arrays are not mergable.
File
- src/
ArrayConfig.php, line 19
Class
- ArrayConfig
- Helper functions to manage configuration stored in arrays.
Namespace
Drupal\little_helpersCode
public static function isMergable(array $value) {
// Short cut for empty arrays.
if (!$value) {
return FALSE;
}
// Numeric arrays are not mergable.
if (array_keys($value) === range(0, count($value) - 1)) {
return FALSE;
}
// Arrays that look like checkbox values are not mergable.
foreach ($value as $k => $v) {
if ($v !== 0 && $k != $v) {
return TRUE;
}
}
return FALSE;
}