Class VCardContact - Stefanius67/VCard GitHub Wiki
Full name: \SKien\VCard\VCardContact
Each contact may contains multiple
- addresses
- communication numbers
- e-mail addresses
- homepages
- categories
Create a new instance of a VCardContact
, set all properties and add the contact
to a vcard using VCard::addContact()
Use VCard::getContactList()
to retrieve list (array) of all contacts within the vcard.
Use VCard::getContact()
to retrieve existing contact within vcard.
See Also:
- \SKien\VCard\VCard::addContact()
- \SKien\VCard\VCard::getContactList()
- \SKien\VCard\VCard::getContact()
Constant | Description |
---|---|
MS_FEMALE |
gender: female (Microsoft specific) |
MS_MALE |
gender: male (Microsoft specific) |
DT_STRING |
Date type: string |
DT_UNIX_TIMESTAMP |
Date type: unix timestamp |
DT_OBJECT |
Date type: DateTime - Object |
Method | Description |
---|---|
addAddress | Add address. |
addCategory | Add a category. |
addEMail | Add mail address. |
addHomepage | Add homepage |
addPhone | Add phone number. |
getAddress | Get address. |
getAddressCount | Number of addresses the contact contains. |
getCategories | Return Categories separated by comma. |
getCategoriesCount | Number of categories contained. |
getCategory | Get category for given index. |
getDateOfBirth | Get date of birth. |
getEMail | Get EMail addres at given index. |
getEMailCount | Number of email addresses contained. |
getFirstName | Get firstname. |
getGender | Get gender. |
getHomepage | Get homepage for given index. |
getHomepageCount | Number of homepages contained. |
getLastName | Get lastname. |
getName | Get full name. |
getNickName | Get nickname. |
getNote | Get annotation. |
getOrganisation | Get name of the organisation. |
getPhone | Get phone number. |
getPhoneCount | Count of phone numbers. |
getPortraitBlob | Get the image as base64 encoded string. |
getPosition | Get position, job title or function within the organisation. |
getPrefix | Get (honorific) name prefix. |
getRole | Get role, occupation or business category within the organisation. |
getSection | Get section or organizational unit within the organisation. |
getSuffix | Get (honorific) name suffix. |
savePortrait | Save portrait as file. |
setDateOfBirth | Set date of birth. |
setGender | Set the gender. |
setHomepage | Set homepage |
setName | Set the full name. |
setNickName | Set nickname. |
setNote | Set annotation. |
setOrganisation | Set name of the organisation. |
setPortraitBlob | Set portrait from base64 encoded image data. |
setPortraitFile | Set portrait from image file. |
setPosition | Set position, job title or function within the organisation. |
setPrefix | Set (honorific) name prefix. |
setRole | Set role, occupation or business category within the organisation. |
setSection | Set section or organizational unit within the organisation. |
setSuffix | Set (honorific) name suffix. |
Add address.
public VCardContact::addAddress(\SKien\VCard\VCardAddress $oAddress, bool $bPreferred) : void
Only one address should be marked as preferred.
Parameters:
Parameter | Type | Description |
---|---|---|
oAddress |
\SKien\VCard\VCardAddress | |
bPreferred |
bool | mark address as preferred. |
Add a category.
public VCardContact::addCategory(string $strCategory) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strCategory |
string |
Add mail address.
public VCardContact::addEMail(string $strEMail, bool $bPreferred) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strEMail |
string | valid e-mail address |
bPreferred |
bool | mark e-mail as preferred |
See Also:
Add homepage
public VCardContact::addHomepage(string $strHomepage) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strHomepage |
string |
Add phone number.
public VCardContact::addPhone(string $strPhone, string|string[] $type, bool $bPreferred) : void
Use to set a communication number (phone, mobile, FAX, ...).
Any combination of the predefined communication number constants plus the definition
HOME or WORK can be specified as the type.
Multiple numbers of the same type can be set within one contact.
Parameters:
Parameter | Type | Description |
---|---|---|
strPhone |
string | the number (SHOULD conform to the semantics of E.164 / X.121) |
type |
string | string[] | one single type or an array of multiple types |
bPreferred |
bool | mark number as preferred |
See Also:
- VCard communication number constants
- https://datatracker.ietf.org/doc/html/rfc2426#section-3.3.1
- https://en.wikipedia.org/wiki/E.164
- https://www.itu.int/rec/T-REC-X.121-200010-I/en
Get address.
public VCardContact::getAddress(int|string $i) : \SKien\VCard\VCardAddress|null
An address can be referenced by index or by type.
For Type requests (=> $i non numeric value):
- The first address matches specified type is used (contact may contains multiple addresses of same type)
- If VCard::PREF is requested, the first preferred address in contact used (even if more than one is defined as preferred), if no preferred address found, the first address within the contact will be returned!
Parameters:
Parameter | Type | Description |
---|---|---|
i |
int | string | reference to address (int => index, string => type) |
Return Type: \SKien\VCard\VCardAddress|null
valid address object or null, if not found
Number of addresses the contact contains.
public VCardContact::getAddressCount() : int
Return Type: int
Return Categories separated by comma.
public VCardContact::getCategories() : string
Return Type: string
Number of categories contained.
public VCardContact::getCategoriesCount() : int
Return Type: int
Get category for given index.
public VCardContact::getCategory(int $i) : string
Parameters:
Parameter | Type | Description |
---|---|---|
i |
int | index (0 <= $i < self::getCategoriesCount() ) |
Return Type: string
Get date of birth.
public VCardContact::getDateOfBirth(int $iType = self::DT_STRING, string $strFormat = 'Y-m-d') : string|int|\DateTime
The return type can be specified in the $iType
parameter:
- self::DT_STRING (default): Date as String in f´the format set with `$strFormat`param (default = 'Y-m-d')
- self::DT_UNIX_TIMESTAMP: Date as unix timestamp
- self::DT_OBJECT: Date as DateTime object
if the property is not set in the contact method returns:
- self::DT_STRING: empty string
- self::DT_UNIX_TIMESTAMP: integer 0
- self::DT_OBJECT: null
Parameters:
Parameter | Type | Description |
---|---|---|
iType |
int | self::DT_STRING (default), self::DT_UNIX_TIMESTAMP or self::DT_OBJECT |
strFormat |
string | Date format compliant to DateTime::format() (default 'Y-m-d') |
Return Type: string|int|\DateTime
See Also:
- https://datatracker.ietf.org/doc/html/rfc2426#section-3.1.5
- https://www.php.net/manual/en/datetime.format.php
Get EMail addres at given index.
public VCardContact::getEMail(int $i) : string
Parameters:
Parameter | Type | Description |
---|---|---|
i |
int | index (0 <= $i < self::getEMailCount() ) |
Return Type: string
Number of email addresses contained.
public VCardContact::getEMailCount() : int
Return Type: int
Get firstname.
public VCardContact::getFirstName() : string
Return Type: string
Get gender.
public VCardContact::getGender() : string
M: "male" F: "female" O: "other" N: "none or not applicable" U: "unknown"
Return Type: string
Get homepage for given index.
public VCardContact::getHomepage(int $i = -1) : string
Parameters:
Parameter | Type | Description |
---|---|---|
i |
int | index (0 <= $i < self::getHomepageCount() ) |
Return Type: string
Number of homepages contained.
public VCardContact::getHomepageCount() : int
Return Type: int
Get lastname.
public VCardContact::getLastName() : string
Return Type: string
Get full name.
public VCardContact::getName() : string
$strFirstName
followed by $strLastName
separeted by blank.
Return Type: string
Get nickname.
public VCardContact::getNickName() : string
Return Type: string
Get annotation.
public VCardContact::getNote() : string
Return Type: string
Get name of the organisation.
public VCardContact::getOrganisation() : string
Return Type: string
Get phone number.
public VCardContact::getPhone(int|string $i) : array<string,string>|null
Requested number can be referenced by index or type.
For index request: 0 <= $i < self::getPhoneCount()
For type requests (=> $i non numeric value):
- first phone matches specified type is used (contact may contains multiple phone numbers of same type)
- if VCard::PREF specified, first number in contact used, if no preferred item found
Parameters:
Parameter | Type | Description |
---|---|---|
i |
int | string | reference to address (int => index, string => type) |
Return Type: array<string,string>|null
Count of phone numbers.
public VCardContact::getPhoneCount() : int
Return Type: int
Get the image as base64 encoded string.
public VCardContact::getPortraitBlob() : string
Return Type: string
base64 encoded image
Get position, job title or function within the organisation.
public VCardContact::getPosition() : string
Return Type: string
Get (honorific) name prefix.
public VCardContact::getPrefix() : string
i.E. 'Dr.', 'Prof.', ...
Return Type: string
Get role, occupation or business category within the organisation.
public VCardContact::getRole() : string
Return Type: string
Get section or organizational unit within the organisation.
public VCardContact::getSection() : string
Return Type: string
Get (honorific) name suffix.
public VCardContact::getSuffix() : string
i.E. 'Jr.', 'M.D.', ...
Return Type: string
Save portrait as file.
public VCardContact::savePortrait(string $strFilename) : void
Supportet types are JPG, PNG, GIF and BMP The type depends on the fileextension. If no extensiomnm given, the type of the imported image will be used.
Parameters:
Parameter | Type | Description |
---|---|---|
strFilename |
string |
Set date of birth.
public VCardContact::setDateOfBirth(string|int|\DateTime $DateOfBirth) : void
Accepts string (format YYYY-MM-DD), int (unixtimestamp) or DateTime - object
Parameters:
Parameter | Type | Description |
---|---|---|
DateOfBirth |
string | int | \DateTime |
Set the gender.
public VCardContact::setGender(string $strGender) : void
There are different posibilities: X-WAB-GENDER MS-extension '1':Female, '2':Male, '9':Unknown X-GENDER Extension 'Female', 'Male'
GENDER vCard v4.0 A single letter - M: "male" - F: "female" - O: "other" - N: "none or not applicable" - U: "unknown".
So we accept everything of this know variants and convert it to the v4.0 single letter when we build the data.
Parameters:
Parameter | Type | Description |
---|---|---|
strGender |
string |
Set homepage
public VCardContact::setHomepage(string $strHomepage) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strHomepage |
string |
Set the full name.
public VCardContact::setName(string $strLastName, string $strFirstName) : void
For companies just leave one of the params blank!
Parameters:
Parameter | Type | Description |
---|---|---|
strLastName |
string | |
strFirstName |
string |
Set nickname.
public VCardContact::setNickName(string $strNickName) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strNickName |
string |
Set annotation.
public VCardContact::setNote(string $strNote) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strNote |
string |
Set name of the organisation.
public VCardContact::setOrganisation(string $strOrganisation) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strOrganisation |
string |
Set portrait from base64 encoded image data.
public VCardContact::setPortraitBlob(string $blobPortrait) : void
Parameters:
Parameter | Type | Description |
---|---|---|
blobPortrait |
string | base64 encoded image |
Set portrait from image file.
public VCardContact::setPortraitFile(string $strFilename) : void
Supported types are JPG, PNG, GIF and BMP.
Note: For transparency the image type itself MUST support transparency (PNG, GIF) and when reading a portrait, it MUST be saved in the same image format!
Parameters:
Parameter | Type | Description |
---|---|---|
strFilename |
string |
Set position, job title or function within the organisation.
public VCardContact::setPosition(string $strPosition) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strPosition |
string |
Set (honorific) name prefix.
public VCardContact::setPrefix(string $strPrefix) : void
i.E. 'Dr.', 'Prof.', ...
Parameters:
Parameter | Type | Description |
---|---|---|
strPrefix |
string |
Set role, occupation or business category within the organisation.
public VCardContact::setRole(string $strRole) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strRole |
string |
Set section or organizational unit within the organisation.
public VCardContact::setSection(string $strSection) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strSection |
string |
Set (honorific) name suffix.
public VCardContact::setSuffix(string $strSuffix) : void
i.E. 'Jr.', 'M.D.', ...
Parameters:
Parameter | Type | Description |
---|---|---|
strSuffix |
string |