forked from sabre-io/vobject
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PHONE-NUMBER value type (used for TEL in vCard 3.0) (sabre-io#486)
Signed-off-by: Christian Kraus <hanzi@hanzi.cc>
- Loading branch information
Showing
5 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Sabre\VObject\Property\VCard; | ||
|
||
use Sabre\VObject\Property; | ||
|
||
/** | ||
* PhoneNumber property. | ||
* | ||
* This object encodes PHONE-NUMBER values. | ||
* | ||
* @author Christian Kraus <christian@kraus.work> | ||
*/ | ||
class PhoneNumber extends Property\Text | ||
{ | ||
protected $structuredValues = []; | ||
|
||
/** | ||
* Returns the type of value. | ||
* | ||
* This corresponds to the VALUE= parameter. Every property also has a | ||
* 'default' valueType. | ||
* | ||
* @return string | ||
*/ | ||
public function getValueType() | ||
{ | ||
return 'PHONE-NUMBER'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Sabre\VObject\Property\VCard; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Sabre\VObject; | ||
|
||
class PhoneNumberTest extends TestCase | ||
{ | ||
public function testParser() | ||
{ | ||
$input = "BEGIN:VCARD\r\nVERSION:3.0\r\nTEL;TYPE=HOME;VALUE=PHONE-NUMBER:+1234\r\nEND:VCARD\r\n"; | ||
|
||
$vCard = VObject\Reader::read($input); | ||
$this->assertInstanceOf('Sabre\VObject\Property\VCard\PhoneNumber', $vCard->TEL); | ||
$this->assertEquals('PHONE-NUMBER', $vCard->TEL->getValueType()); | ||
$this->assertEquals($input, $vCard->serialize()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters