Skip to content

Commit

Permalink
Fix TYPE attributes for TEL and EMAIL properties
Browse files Browse the repository at this point in the history
This PR fixes jeroendesloovere#203 jeroendesloovere#204

This commit is from:
jeroendesloovere#205

Cherry-picked from 7f090cc.
  • Loading branch information
p-w authored and lkmorlan committed Aug 25, 2024
1 parent 8713e08 commit da873bc
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/VCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
);

Expand Down

0 comments on commit da873bc

Please sign in to comment.