Chris@14: , Sebastian Heuer , Sebastian Bergmann Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace PharIo\Manifest; Chris@14: Chris@14: class Email { Chris@14: /** Chris@14: * @var string Chris@14: */ Chris@14: private $email; Chris@14: Chris@14: /** Chris@14: * @param string $email Chris@14: * Chris@14: * @throws InvalidEmailException Chris@14: */ Chris@14: public function __construct($email) { Chris@14: $this->ensureEmailIsValid($email); Chris@14: Chris@14: $this->email = $email; Chris@14: } Chris@14: Chris@14: /** Chris@14: * @return string Chris@14: */ Chris@14: public function __toString() { Chris@14: return $this->email; Chris@14: } Chris@14: Chris@14: /** Chris@14: * @param string $url Chris@14: * Chris@14: * @throws InvalidEmailException Chris@14: */ Chris@14: private function ensureEmailIsValid($url) { Chris@14: if (filter_var($url, \FILTER_VALIDATE_EMAIL) === false) { Chris@14: throw new InvalidEmailException; Chris@14: } Chris@14: } Chris@14: }