You are here

public function EmailParser::parse in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/egulias/email-validator/src/Egulias/EmailValidator/EmailParser.php \Egulias\EmailValidator\EmailParser::parse()

Parameters

$str:

Return value

array

File

vendor/egulias/email-validator/src/Egulias/EmailValidator/EmailParser.php, line 35

Class

EmailParser
EmailParser

Namespace

Egulias\EmailValidator

Code

public function parse($str) {
  $this->lexer
    ->setInput($str);
  if (!$this
    ->hasAtToken()) {
    throw new \InvalidArgumentException('ERR_NOLOCALPART');
  }
  $this->localPartParser
    ->parse($str);
  $this->domainPartParser
    ->parse($str);
  $this
    ->setParts($str);
  if ($this->lexer
    ->hasInvalidTokens()) {
    throw new \InvalidArgumentException('ERR_INVALID_ATEXT');
  }
  return array(
    'local' => $this->localPart,
    'domain' => $this->domainPart,
  );
}