- foreach ($data as $item) {
- $phone = new Phone($item);
- $success = (!$phone->error && ($phone->format() || $phone->isEmpty()) && $success);
- if (!$phone->isEmpty()) {
- if (!is_null($maxPublicity) && $maxPublicity->isVisible($phone->pub)) {
- $phone->pub = $maxPublicity->level();
+ 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));