Skip to content

Commit

Permalink
file element
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreLebedel committed Oct 24, 2024
1 parent 1b6e7ed commit 776b38f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/Elements/VCardFileElement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Pleb\VCardIO\Elements;

use stdClass;

class VCardFileElement extends VCardElement
{
public function outputValue(): mixed
{

$object = new stdClass;
$object->value = $this->inputValue;
$object->type = !empty($this->types) ? implode(';', $this->types) : 'default';

return $object;
}
}
4 changes: 3 additions & 1 deletion src/Elements/VCardMultipleTypedElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions src/VCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ class VCard

public $agent = null;

public $photo = null;

public $logo = null;

public $sound = null;

public array $unparsedData = [];
}
7 changes: 4 additions & 3 deletions src/VCardParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' => ,
Expand Down

0 comments on commit 776b38f

Please sign in to comment.