From 8d42743be8d0df6d06fd8bacef9864bed85140c6 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 25 Jul 2022 11:29:37 +0200 Subject: [PATCH] Update VCard.php This PR fixes #203 #204 https://github.com/jeroendesloovere/vcard/pull/205 --- src/VCard.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/VCard.php b/src/VCard.php index 8ccc6c4..0652110 100644 --- a/src/VCard.php +++ b/src/VCard.php @@ -148,21 +148,24 @@ public function addCompany($company, $department = '') * * @param string $address The e-mail address * @param string [optional] $type The type of the email address - * $type may be PREF | WORK | HOME - * or any combination of these: e.g. "PREF;WORK" + * $type may be WORK | HOME + * or any combination of these: e.g. "WORK" + * @param boolean [optional] $pref + * Set this number as preferred with pref = 1 * @return $this */ - public function addEmail($address, $type = '') + public function addEmail($address, $type = '', $pref = 0) { $this->setProperty( 'email', - 'EMAIL;INTERNET' . (($type != '') ? ';' . $type : ''), + 'EMAIL;INTERNET' . (($pref == 1) ? ';PREF=' . $pref : '') . (($type != '') ? ';' . $type : ''), $address ); return $this; } + /** * Add jobtitle * @@ -406,16 +409,18 @@ public function addCategories($categories) * * @param string $number * @param string [optional] $type - * Type may be PREF | WORK | HOME | VOICE | FAX | MSG | + * Type may be WORK | HOME | VOICE | FAX | MSG | * CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO - * or any senseful combination, e.g. "PREF;WORK;VOICE" + * or any senseful combination, e.g. "WORK,VOICE" + * @param boolean [optional] $pref + * Set this number as preferred with pref = 1 * @return $this */ - public function addPhoneNumber($number, $type = '') + public function addPhoneNumber($number, $type = '', $pref = 0) { $this->setProperty( 'phoneNumber', - 'TEL' . (($type != '') ? ';' . $type : ''), + 'TEL' . (($pref == 1) ? ';PREF=' . $pref : '') . (($type != '') ? ';TYPE=' . $type : ''), $number );