#4 - Performance updated and housekeeping

This commit is contained in:
Eduardo Gulias Davis
2013-06-30 16:04:11 +02:00
parent 0cb5e361d5
commit 5d82c6c6a2
2 changed files with 4 additions and 7 deletions
+3 -4
View File
@@ -11,9 +11,7 @@ class EmailParser
{
protected $warnings = array();
protected $localPart = '';
protected $domainPart = '';
protected $index = 0;
public function __construct(EmailLexer $lexer)
{
@@ -37,8 +35,9 @@ class EmailParser
}
$this->parseLocalPart();
$this->parseDomainPart();
$parts = explode('@', $str);
if (strlen($this->localPart . '@' . $this->domainPart) > 254) {
if (strlen($parts[0] . '@' . $this->domainPart) > 254) {
// http://tools.ietf.org/html/rfc5321#section-4.1.2
// Forward-path = Path
//
@@ -49,7 +48,7 @@ class EmailParser
$this->warnings[] = EmailValidator::RFC5322_TOOLONG;
}
return array('local' => $this->localPart, 'domain' => $this->domainPart);
return array('local' => $parts[0], 'domain' => $this->domainPart);
}
/**
@@ -1,6 +1,6 @@
<?php
use egulias\EmailValidator\EmailValidator;
use Egulias\EmailValidator\EmailValidator;
require __DIR__ . '/../../bootstrap.php';
@@ -31,5 +31,3 @@ for ($i = 0; $i < $iterations; $i++) {
}
$b = microtime(true);
echo ($b - $a) . ' seconds with EmailValidator once instanced' . PHP_EOL;