Source
xxxxxxxxxx
1408
1408
break;
1409
1409
}
1410
1410
1411
1411
return array_intersect_key($details, array_flip($field_names));
1412
1412
}
1413
1413
1414
1414
/**
1415
1415
* Get summary interface availability status.
1416
1416
*
1417
1417
* @param array $interfaces
1418
-
* @param bool $has_enabled_items
1419
1418
*
1420
1419
* @return int
1421
1420
*/
1422
-
function getInterfaceAvailabilityStatus(array $interfaces, bool $has_enabled_items = true): int {
1423
-
if ($has_enabled_items) {
1424
-
$interfaces_with_enabled_items = array_filter($interfaces, static function ($interface) {
1425
-
return array_key_exists('has_enabled_items', $interface) && $interface['has_enabled_items'];
1426
-
});
1421
+
function getInterfaceAvailabilityStatus(array $interfaces): int {
1422
+
$interfaces_with_enabled_items = array_filter($interfaces,
1423
+
static fn ($interface) => $interface['has_enabled_items']
1424
+
);
1427
1425
1428
-
$interfaces = $interfaces_with_enabled_items ?: $interfaces;
1429
-
}
1426
+
$interfaces = $interfaces_with_enabled_items ?: $interfaces;
1430
1427
1431
1428
$available = array_column($interfaces, 'available');
1432
1429
1433
1430
if (in_array(INTERFACE_AVAILABLE_MIXED, $available)) {
1434
1431
return INTERFACE_AVAILABLE_MIXED;
1435
1432
}
1436
1433
1437
1434
if (in_array(INTERFACE_AVAILABLE_FALSE, $available)) {
1438
1435
return in_array(INTERFACE_AVAILABLE_UNKNOWN, $available)
1439
1436
|| in_array(INTERFACE_AVAILABLE_TRUE, $available)