Skip to content

Instantly share code, notes, and snippets.

@Astikos
Created February 21, 2023 06:15
Show Gist options
  • Save Astikos/705ee29b59099068e21d789448dd2bf5 to your computer and use it in GitHub Desktop.
Save Astikos/705ee29b59099068e21d789448dd2bf5 to your computer and use it in GitHub Desktop.
<?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