Created
December 12, 2016 13:08
-
-
Save brzuchal/fafc96c4ccfe4e40c5994d9c539c86a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Plumbok\Test; | |
/** | |
* @Value | |
*/ | |
class Email | |
{ | |
private $email = ''; | |
private function setEmail(string $email) | |
{ | |
if (!valid($email)) { | |
throw new InvalidArgumentException("Email address is invalid, given: {$email}"); | |
} | |
$this->email = $email; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Plumbok\Test; | |
/** | |
* @Value | |
*/ | |
class Email | |
{ | |
private $email = ''; | |
private function setEmail(string $email) | |
{ | |
if (!valid($email)) { | |
throw new InvalidArgumentException("Email address is invalid, given: {$email}"); | |
} | |
$this->email = $email; | |
} | |
// generated code | |
/** | |
* Email constructor. | |
* | |
* @param string $email | |
*/ | |
public function __construct(string $email) | |
{ | |
$this->setEmail($email); | |
} | |
/** | |
* Retrieves email | |
* | |
* @return string | |
*/ | |
public function getEmail() : string | |
{ | |
return $this->email; | |
} | |
/** | |
* Compares two emails | |
* | |
* @return boolean | |
*/ | |
public function equal(Email $other) : bool | |
{ | |
return get_class($this) === get_class($other) && $this->email == $other->email; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment