1 | <?php |
||
25 | class EmailAddress |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * The local part of the email address (before the '@' sign). |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $localPart; |
||
34 | |||
35 | /** |
||
36 | * The domain part of the email address (after the '@' sign). |
||
37 | * |
||
38 | * @var Domain |
||
39 | */ |
||
40 | protected $domain; |
||
41 | |||
42 | /** |
||
43 | * Instantiate an EmailAddress object. |
||
44 | * |
||
45 | * @param EmailAddress|string $email The email to parse. |
||
46 | * |
||
47 | * @throws InvalidEmailAddress If the email is not valid. |
||
48 | */ |
||
49 | 8 | public function __construct($email) |
|
68 | |||
69 | /** |
||
70 | * Returns the local part of the email address. |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | 2 | public function getLocalPart() |
|
78 | |||
79 | /** |
||
80 | * Returns the domain part of the email address. |
||
81 | * |
||
82 | * @return Domain |
||
83 | */ |
||
84 | 2 | public function getDomain() |
|
88 | |||
89 | /** |
||
90 | * Returns the entire email address. |
||
91 | * |
||
92 | * @return string |
||
93 | */ |
||
94 | 2 | public function getAddress() |
|
98 | |||
99 | /** |
||
100 | * Convert the EmailAddress object to a string. |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | 2 | public function __toString() |
|
108 | |||
109 | /** |
||
110 | * Check whether an email is valid. |
||
111 | * |
||
112 | * @param string $email Email to check. |
||
113 | * |
||
114 | * @return bool Whether the email is valid. |
||
115 | */ |
||
116 | 7 | protected function isValid($email) |
|
120 | } |