ensureValueIsValid($value); $this->value = $value; } /** @inheritDoc */ public function jsonSerialize(): string { return $this->value; } /** * @param string $value * @return void * @throws InvalidValueException */ private function ensureValueIsValid(string $value) { if (!filter_var($value, FILTER_VALIDATE_EMAIL)) { throw new InvalidValueException(sprintf( '<%s> does not allow the value <%s>.', static::class, $value )); } } }