Skip to content

Commit

Permalink
Add label to VcardParser
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen Desloovere authored and Jeroen Desloovere committed Nov 24, 2021
1 parent c0e306f commit 2b8b619
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/VCardParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ protected function parse()
case 'CATEGORIES':
$cardData->categories = array_map('trim', explode(',', $value));
break;
case 'LABEL':
$cardData->label = $value;
break;
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions tests/VCardParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,13 @@ public function testFileNotFound()
{
$parser = VCardParser::parseFromFile(__DIR__ . '/does-not-exist.vcf');
}

public function testLabel()
{
$label = 'street, worktown, workpostcode Belgium';
$vcard = new VCard();
$vcard->addLabel($label, 'work');
$parser = new VCardParser($vcard->buildVCard());
$this->assertEquals($parser->getCardAtIndex(0)->label, $label);
}
}

0 comments on commit 2b8b619

Please sign in to comment.