Skip to content

Commit

Permalink
Change getBySelfURL to use same node interpretation logic as getAll
Browse files Browse the repository at this point in the history
  • Loading branch information
DivineOmega authored Nov 18, 2016
1 parent ff2bf5e commit f98d20f
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions factories/ContactFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,28 @@ public static function getBySelfURL($selfURL)
}

$contactGDNodes = $xmlContactsEntry->children('http://schemas.google.com/g/2005');

foreach ($contactGDNodes as $key => $value) {
$attributes = $value->attributes();

if ($key == 'email') {
$contactDetails[$key] = (string) $attributes['address'];
} else {
$contactDetails[$key] = (string) $value;
switch ($key) {
case 'organization':
$contactDetails[$key]['orgName'] = (string) $value->orgName;
$contactDetails[$key]['orgTitle'] = (string) $value->orgTitle;
break;
case 'email':
$attributes = $value->attributes();
$emailadress = (string) $attributes['address'];
$emailtype = substr(strstr($attributes['rel'], '#'), 1);
$contactDetails[$key][] = ['type' => $emailtype, 'email' => $emailadress];
break;
case 'phoneNumber':
$attributes = $value->attributes();
$uri = (string) $attributes['uri'];
$type = substr(strstr($attributes['rel'], '#'), 1);
$e164 = substr(strstr($uri, ':'), 1);
$contactDetails[$key][] = ['type' => $type, 'number' => $e164];
break;
default:
$contactDetails[$key] = (string) $value;
break;
}
}

Expand Down

0 comments on commit f98d20f

Please sign in to comment.