Download the PHP package nordic/email-address without Composer
On this page you can find all versions of the php package nordic/email-address. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nordic/email-address
More information about nordic/email-address
Files in nordic/email-address
Package email-address
Short Description Immutable Email Address value object
License MIT
Homepage https://github.com/nordic-alliance/email-address
Informations about the package email-address
Email Address immutable value object
This package represents an immutable email address value object and additional utility classes.
Install
Via Composer
Features
- Immutable value object
- No dependencies
- Include null email address value object (see Null object pattern)
- Include assertion class
- Include factory class
Basic classes and interfaces
EmailAddressInterface
- is the base interface for email address value objects.
EmailAddress
- immutable email address value object that will be used most of the time.
NullEmailAddress
- null email address value object (null object design pattern).
Usage
Exceptions
InvalidEmailAddressException
- is a basic exception that you can use. The first argument is a string value.
Factory pattern
EmailAddressFactoryInterface
- is the base interface for email address factory.
EmailAddressFactory
- is the factory class that creates EmailAddress
value objects.
Assertion
The class Assertion
can be used for checking if string value is an email address string or check if email address value object is not null object. All methods will throw InvalidEmailAddressException
if assertion will fails. You can always set a custom exception message as the second method argument.
Available methods:
Assertion::email
- will fail in case if string value is not a valid email address.Assertion::notNull
- will fail in case if email address value object is null email address object.
Additional helpers
Provider interface and trait
Use interface EmailAddressProviderInterface
and trait EmailAddressProviderTrait
when the object should only provide email address value object (see EmailAddressProviderTest.php for examples).
Aware intrerface and trait
Use interface EmailAddressAwareInterface
and trait EmailAddressAwareTrait
when the object should aware about email address value object (see EmailAddressAwareTest.php for examples).
Example
Testing
Credits
- Serhii Diahovchenko
- All Contributors
License
The MIT License (MIT). Please see License File for more information.