<?php
 namespace Eluceo\iCal\Domain\ValueObject; use InvalidArgumentException; final class EmailAddress { private string $emailAddress; public function __construct(string $emailAddress) { if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) { throw new InvalidArgumentException("$emailAddress is no valid e-mail address"); } $this->emailAddress = $emailAddress; } public function getEmailAddress(): string { return $this->emailAddress; } public function toUri(): Uri { return new Uri('mailto:' . $this->emailAddress); } } 