Value Object Email

v1.0.0 2021-04-19 00:32 UTC

This package is auto-updated.

Last update: 2024-12-19 11:08:39 UTC


README

Latest Stable Version Total Downloads License PHP

Email

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