/** * Converts a ContactInformation object into a vcard * * @param \Prototype\ContactInformation $contact contact information to convert * @return \Sabre\VObject\Component\VCard created vcard */ public function convert(ContactInformation $contact) { $vcard = new VObject\Component\VCard(); if ($contact->hasAttribute('lastname') || $contact->hasAttribute('firstname') || $contact->hasAttribute('additionalNames') || $contact->hasAttribute('honorificPrefixes') || $contact->hasAttribute('honorificSuffixes')) { $N = [$contact->hasAttribute('lastname') ? $contact->getAttribute('lastname') : '', $contact->hasAttribute('firstname') ? $contact->getAttribute('firstname') : '', $contact->hasAttribute('additionalNames') ? $contact->getAttribute('additionalNames') : '', $contact->hasAttribute('honorificPrefixes') ? $contact->getAttribute('honorificPrefixes') : '', $contact->hasAttribute('honorificSuffixes') ? $contact->getAttribute('honorificSuffixes') : '']; $vcard->add('N', $N); } foreach (self::$attributeMap as $key => $value) { if ($contact->hasAttribute($key)) { $vcard->add($value, $contact->getAttribute($key)); } } return $vcard; }