Skip to content

Instantly share code, notes, and snippets.

Created Oct 15, 2020
What would you like to do?
Value object external validation
final class Country
private string $countryCode;
private function __construct(string $countryCode)
$this->countryCode = $countryCode;
* @param callable(string): bool $f
public static function existing(callable $exists, string $countryCode): self
if (!$exists($countryCode)) {
throw new \Exception('no no no!!!')
return new self($countryCode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment