parser = new EmailParser($emailLexer); try { $result = $this->parser->parse((string)$email); if ($result->isInvalid()) { $this->error = $result; return false; } } catch (ExceptionInvalidEmail $invalid) { $this->error = $invalid; return false; } $this->warnings = $this->parser->getWarnings(); return true; } public function getError() : ?InvalidEmail { return $this->error; } public function getWarnings() { return $this->warnings; } }