From 776b38f451aca5f9170c0a2e5261a4c85b1fc3fe Mon Sep 17 00:00:00 2001 From: PierreLebedel Date: Thu, 24 Oct 2024 18:31:53 +0200 Subject: [PATCH] file element --- src/Elements/VCardFileElement.php | 20 ++++++++++++++++++++ src/Elements/VCardMultipleTypedElement.php | 4 +++- src/VCard.php | 6 ++++++ src/VCardParser.php | 7 ++++--- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 src/Elements/VCardFileElement.php diff --git a/src/Elements/VCardFileElement.php b/src/Elements/VCardFileElement.php new file mode 100644 index 0000000..0757a43 --- /dev/null +++ b/src/Elements/VCardFileElement.php @@ -0,0 +1,20 @@ +value = $this->inputValue; + $object->type = !empty($this->types) ? implode(';', $this->types) : 'default'; + + return $object; + } +} diff --git a/src/Elements/VCardMultipleTypedElement.php b/src/Elements/VCardMultipleTypedElement.php index 2614284..e706ec5 100644 --- a/src/Elements/VCardMultipleTypedElement.php +++ b/src/Elements/VCardMultipleTypedElement.php @@ -17,7 +17,9 @@ public function outputValue(): mixed { $object = new stdClass; $object->value = $this->inputValue; - $object->type = implode(';', array_intersect($this->types, $this->restrictedTypes)) ?? 'default'; + + $types = array_intersect($this->types, $this->restrictedTypes); + $object->type = !empty($types) ? implode(';', $types) : 'default'; return $object; } diff --git a/src/VCard.php b/src/VCard.php index 335db43..ab01e6c 100644 --- a/src/VCard.php +++ b/src/VCard.php @@ -37,5 +37,11 @@ class VCard public $agent = null; + public $photo = null; + + public $logo = null; + + public $sound = null; + public array $unparsedData = []; } diff --git a/src/VCardParser.php b/src/VCardParser.php index 6dc4fd3..eb31a67 100644 --- a/src/VCardParser.php +++ b/src/VCardParser.php @@ -8,6 +8,7 @@ use Pleb\VCardIO\Elements\VCardElement; use Pleb\VCardIO\Elements\VCardGeoElement; use Pleb\VCardIO\Elements\VCardUriElement; +use Pleb\VCardIO\Elements\VCardFileElement; use Pleb\VCardIO\Elements\VCardNameElement; use Pleb\VCardIO\Elements\VCardFloatElement; use Pleb\VCardIO\Elements\VCardAddressElement; @@ -231,21 +232,21 @@ protected function parseLine(int $lineNumber, string $lineContents): void //'kind' => , 'label' => (new VCardAddressElement($value, $types))->typed(['dom', 'intl', 'postal', 'parcel', 'home', 'work', 'pref']), //'lang' => , - //'logo' => , + 'logo' => (new VCardFileElement($value, $types)), //'mailer' => , //'member' => , 'n' => (new VCardNameElement($value)), 'nickname' => (new VCardMultipleElement($value)), //'note' => , 'org' => (new VCardOrganizationElement($value)), - //'photo' => , + 'photo' => (new VCardFileElement($value, $types)), //'prodid' => , //'profile' => , //'related' => , //'rev' => , //'role' => , //'sort-string' => , - //'sound' => , + 'sound' => (new VCardFileElement($value, $types)), //'source' => , 'tel' => (new VCardMultipleTypedElement($value, $types))->typed(['home', 'msg', 'work', 'pref', 'voice', 'fax', 'cell', 'video', 'pager', 'bbs', 'modem', 'car', 'isdn', 'pcs']), //'title' => ,