value-object / email
Value Object Email
v1.0.0
2021-04-19 00:32 UTC
Requires
- php: >= 7.1
Requires (Dev)
- phpunit/phpunit: ^4.8.35 || ^5.7 || ^6.5 || ^7.5 || ^8.5 || 9.3
- squizlabs/php_codesniffer: ^3.5
README
PHP email value-object.
Install
composer require value-object/email:^1.0
Using
<?php require_once('vendor/autoload.php'); $value = new ValueObject\Email\EmailAddress('tyler@fight.club'); echo $value->getHost(); // fight.club echo $value->getUser(); // tyler echo $value->getEmail(); // tyler@fight.club echo $value->getValue(); // tyler@fight.club $value = new ValueObject\Email\EmailAddress('tyler+mayhem@fight.club'); echo $value->getHost(); // fight.club echo $value->getUser(); // tyler echo $value->getTag(); // mayhem echo $value->getEmail(); // tyler+mayhem@fight.club echo $value->getValue(); // tyler+mayhem@fight.club $value = new ValueObject\Email\EmailAddress('Tyler Durden <tyler@fight.club>'); echo $value->getHost(); // fight.club echo $value->getUser(); // tyler echo $value->getEmail(); // tyler@fight.club echo $value->getName(); // Tyler Durden echo $value->getValue(); // Tyler Durden <tyler@fight.club> $value = new ValueObject\Email\EmailAddress('"R. Paulson" <bob@fight.club>'); echo $value->getHost(); // fight.club echo $value->getUser(); // bob echo $value->getEmail(); // bob@fight.club echo $value->getName(); // R. Paulson echo $value->getValue(); // "R. Paulson" <tyler@fight.club> $value = new ValueObject\Email\EmailAddress('email'); // throws InvalidArgumentException