Created
February 21, 2023 06:15
-
-
Save Astikos/705ee29b59099068e21d789448dd2bf5 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 App\Entity; | |
class Email | |
{ | |
private ?int $id; | |
private string $email; | |
public function __construct(?int $id, string $email) | |
{ | |
$this->id = $id; | |
$this->email = strtolower($email); | |
} | |
public function getId(): ?int | |
{ | |
return $this->id; | |
} | |
public function returnNonNullId(): int | |
{ | |
if (null === $this->id) { | |
throw new \LogicException(sprintf('id should not be null for Email %s', $this->email)); | |
} | |
return $this->id; | |
} | |
public function setId(int $id): void | |
{ | |
$this->id = $id; | |
} | |
public function getEmail(): string | |
{ | |
return $this->email; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment