getCompany(); $location = $e->getLocation(); $lines = []; $lines[] = 'BEGIN:VCARD'; $lines[] = 'VERSION:3.0'; $lines[] = 'N:'.$this->esc($e->getLastName()).';'.$this->esc($e->getFirstName()).';;;'; $lines[] = 'FN:'.$this->esc(trim($e->getFirstName().' '.$e->getLastName())); if ($company) { $lines[] = 'ORG:'.$this->esc($company->getName()); } if ($e->getPosition()) { $lines[] = 'TITLE:'.$this->esc($e->getPosition()); } if ($e->getEmail()) { $lines[] = 'EMAIL;TYPE=WORK:'.$this->esc($e->getEmail()); } if ($e->getPhone()) { $lines[] = 'TEL;TYPE=WORK,VOICE:'.$this->esc($e->getPhone()); } if ($e->getMobile()) { $lines[] = 'TEL;TYPE=CELL:'.$this->esc($e->getMobile()); } if ($location && ($location->getStreet() || $location->getCity())) { // ADR: ;;Straße;Ort;;PLZ;Land $lines[] = 'ADR;TYPE=WORK:;;' .$this->esc((string) $location->getStreet()).';' .$this->esc((string) $location->getCity()).';;' .$this->esc((string) $location->getPostalCode()).';' .$this->esc((string) $location->getCountry()); } foreach ($e->getContactLinks() as $link) { $lines[] = 'URL:'.$this->esc($link->getUrl()); } if ($e->getBio()) { $lines[] = 'NOTE:'.$this->esc($e->getBio()); } $lines[] = 'REV:'.$e->getUpdatedAt()->format('Ymd\THis\Z'); $lines[] = 'END:VCARD'; // vCard verlangt CRLF-Zeilenenden return implode("\r\n", $lines)."\r\n"; } /** Escaping gemäß vCard-Spezifikation. */ private function esc(string $value): string { return str_replace( ['\\', "\n", ',', ';'], ['\\\\', '\\n', '\\,', '\\;'], $value, ); } }