private static function formArrayWalk(array $data, $function, &$success = true, $requiresEmptyPhone = false, $maxPublicity = null) { $phones = array(); if (!is_null($data)) { foreach ($data as $item) { $phone = new Phone($item); $success = !$phone->error && ($phone->format() || $phone->isEmpty()) && $success; if (!$phone->isEmpty()) { // Restrict phone visibility to $maxPublicity if (!is_null($maxPublicity) && Visibility::isLessRestrictive($maxPublicity, $phone->pub)) { $phone->pub = $maxPublicity; } $phones[] = call_user_func(array($phone, $function)); } } } if (count($phones) == 0 && $requiresEmptyPhone) { $phone = new Phone(); if (!is_null($maxPublicity) && Visibility::isLessRestrictive($maxPublicity, $phone->pub)) { // Restrict phone visibility to $maxPublicity $phone->pub = $maxPublicity; } $phones[] = call_user_func(array($phone, $function)); } return $phones; }