@@ -11,12 +11,12 @@ |
||
11 | 11 | require __DIR__.'/classes/Swift.php'; |
12 | 12 | |
13 | 13 | Swift::registerAutoload(function () { |
14 | - // Load in dependency maps |
|
15 | - require __DIR__.'/dependency_maps/cache_deps.php'; |
|
16 | - require __DIR__.'/dependency_maps/mime_deps.php'; |
|
17 | - require __DIR__.'/dependency_maps/message_deps.php'; |
|
18 | - require __DIR__.'/dependency_maps/transport_deps.php'; |
|
14 | + // Load in dependency maps |
|
15 | + require __DIR__.'/dependency_maps/cache_deps.php'; |
|
16 | + require __DIR__.'/dependency_maps/mime_deps.php'; |
|
17 | + require __DIR__.'/dependency_maps/message_deps.php'; |
|
18 | + require __DIR__.'/dependency_maps/transport_deps.php'; |
|
19 | 19 | |
20 | - // Load in global library preferences |
|
21 | - require __DIR__.'/preferences.php'; |
|
20 | + // Load in global library preferences |
|
21 | + require __DIR__.'/preferences.php'; |
|
22 | 22 | }); |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | require __DIR__.'/classes/Swift.php'; |
12 | 12 | |
13 | -Swift::registerAutoload(function () { |
|
13 | +Swift::registerAutoload(function() { |
|
14 | 14 | // Load in dependency maps |
15 | 15 | require __DIR__.'/dependency_maps/cache_deps.php'; |
16 | 16 | require __DIR__.'/dependency_maps/mime_deps.php'; |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | namespace Egulias; |
8 | 8 | |
9 | -require_once __DIR__ . '/egulias/email-validator/AutoLoader.php'; |
|
9 | +require_once __DIR__.'/egulias/email-validator/AutoLoader.php'; |
|
10 | 10 | |
11 | 11 | $autoloader = new EguliasAutoLoader(__NAMESPACE__, dirname(__DIR__)); |
12 | 12 |
@@ -15,123 +15,123 @@ |
||
15 | 15 | */ |
16 | 16 | class EmailParser |
17 | 17 | { |
18 | - const EMAIL_MAX_LENGTH = 254; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - protected $warnings = []; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $domainPart = ''; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - protected $localPart = ''; |
|
34 | - /** |
|
35 | - * @var EmailLexer |
|
36 | - */ |
|
37 | - protected $lexer; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var LocalPart |
|
41 | - */ |
|
42 | - protected $localPartParser; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var DomainPart |
|
46 | - */ |
|
47 | - protected $domainPartParser; |
|
48 | - |
|
49 | - public function __construct(EmailLexer $lexer) |
|
50 | - { |
|
51 | - $this->lexer = $lexer; |
|
52 | - $this->localPartParser = new LocalPart($this->lexer); |
|
53 | - $this->domainPartParser = new DomainPart($this->lexer); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @param string $str |
|
58 | - * @return array |
|
59 | - */ |
|
60 | - public function parse($str) |
|
61 | - { |
|
62 | - $this->lexer->setInput($str); |
|
63 | - |
|
64 | - if (!$this->hasAtToken()) { |
|
65 | - throw new NoLocalPart(); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - $this->localPartParser->parse($str); |
|
70 | - $this->domainPartParser->parse($str); |
|
71 | - |
|
72 | - $this->setParts($str); |
|
73 | - |
|
74 | - if ($this->lexer->hasInvalidTokens()) { |
|
75 | - throw new ExpectingATEXT(); |
|
76 | - } |
|
77 | - |
|
78 | - return array('local' => $this->localPart, 'domain' => $this->domainPart); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @return Warning\Warning[] |
|
83 | - */ |
|
84 | - public function getWarnings() |
|
85 | - { |
|
86 | - $localPartWarnings = $this->localPartParser->getWarnings(); |
|
87 | - $domainPartWarnings = $this->domainPartParser->getWarnings(); |
|
88 | - $this->warnings = array_merge($localPartWarnings, $domainPartWarnings); |
|
89 | - |
|
90 | - $this->addLongEmailWarning($this->localPart, $this->domainPart); |
|
91 | - |
|
92 | - return $this->warnings; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function getParsedDomainPart() |
|
99 | - { |
|
100 | - return $this->domainPart; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @param string $email |
|
105 | - */ |
|
106 | - protected function setParts($email) |
|
107 | - { |
|
108 | - $parts = explode('@', $email); |
|
109 | - $this->domainPart = $this->domainPartParser->getDomainPart(); |
|
110 | - $this->localPart = $parts[0]; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @return bool |
|
115 | - */ |
|
116 | - protected function hasAtToken() |
|
117 | - { |
|
118 | - $this->lexer->moveNext(); |
|
119 | - $this->lexer->moveNext(); |
|
120 | - if ($this->lexer->token['type'] === EmailLexer::S_AT) { |
|
121 | - return false; |
|
122 | - } |
|
123 | - |
|
124 | - return true; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @param string $localPart |
|
129 | - * @param string $parsedDomainPart |
|
130 | - */ |
|
131 | - protected function addLongEmailWarning($localPart, $parsedDomainPart) |
|
132 | - { |
|
133 | - if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { |
|
134 | - $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); |
|
135 | - } |
|
136 | - } |
|
18 | + const EMAIL_MAX_LENGTH = 254; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + protected $warnings = []; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $domainPart = ''; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + protected $localPart = ''; |
|
34 | + /** |
|
35 | + * @var EmailLexer |
|
36 | + */ |
|
37 | + protected $lexer; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var LocalPart |
|
41 | + */ |
|
42 | + protected $localPartParser; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var DomainPart |
|
46 | + */ |
|
47 | + protected $domainPartParser; |
|
48 | + |
|
49 | + public function __construct(EmailLexer $lexer) |
|
50 | + { |
|
51 | + $this->lexer = $lexer; |
|
52 | + $this->localPartParser = new LocalPart($this->lexer); |
|
53 | + $this->domainPartParser = new DomainPart($this->lexer); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @param string $str |
|
58 | + * @return array |
|
59 | + */ |
|
60 | + public function parse($str) |
|
61 | + { |
|
62 | + $this->lexer->setInput($str); |
|
63 | + |
|
64 | + if (!$this->hasAtToken()) { |
|
65 | + throw new NoLocalPart(); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + $this->localPartParser->parse($str); |
|
70 | + $this->domainPartParser->parse($str); |
|
71 | + |
|
72 | + $this->setParts($str); |
|
73 | + |
|
74 | + if ($this->lexer->hasInvalidTokens()) { |
|
75 | + throw new ExpectingATEXT(); |
|
76 | + } |
|
77 | + |
|
78 | + return array('local' => $this->localPart, 'domain' => $this->domainPart); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @return Warning\Warning[] |
|
83 | + */ |
|
84 | + public function getWarnings() |
|
85 | + { |
|
86 | + $localPartWarnings = $this->localPartParser->getWarnings(); |
|
87 | + $domainPartWarnings = $this->domainPartParser->getWarnings(); |
|
88 | + $this->warnings = array_merge($localPartWarnings, $domainPartWarnings); |
|
89 | + |
|
90 | + $this->addLongEmailWarning($this->localPart, $this->domainPart); |
|
91 | + |
|
92 | + return $this->warnings; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function getParsedDomainPart() |
|
99 | + { |
|
100 | + return $this->domainPart; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @param string $email |
|
105 | + */ |
|
106 | + protected function setParts($email) |
|
107 | + { |
|
108 | + $parts = explode('@', $email); |
|
109 | + $this->domainPart = $this->domainPartParser->getDomainPart(); |
|
110 | + $this->localPart = $parts[0]; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @return bool |
|
115 | + */ |
|
116 | + protected function hasAtToken() |
|
117 | + { |
|
118 | + $this->lexer->moveNext(); |
|
119 | + $this->lexer->moveNext(); |
|
120 | + if ($this->lexer->token['type'] === EmailLexer::S_AT) { |
|
121 | + return false; |
|
122 | + } |
|
123 | + |
|
124 | + return true; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @param string $localPart |
|
129 | + * @param string $parsedDomainPart |
|
130 | + */ |
|
131 | + protected function addLongEmailWarning($localPart, $parsedDomainPart) |
|
132 | + { |
|
133 | + if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { |
|
134 | + $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); |
|
135 | + } |
|
136 | + } |
|
137 | 137 | } |
@@ -130,7 +130,7 @@ |
||
130 | 130 | */ |
131 | 131 | protected function addLongEmailWarning($localPart, $parsedDomainPart) |
132 | 132 | { |
133 | - if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { |
|
133 | + if (strlen($localPart.'@'.$parsedDomainPart) > self::EMAIL_MAX_LENGTH) { |
|
134 | 134 | $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); |
135 | 135 | } |
136 | 136 | } |
@@ -4,14 +4,14 @@ |
||
4 | 4 | |
5 | 5 | class QuotedString extends Warning |
6 | 6 | { |
7 | - const CODE = 11; |
|
7 | + const CODE = 11; |
|
8 | 8 | |
9 | - /** |
|
10 | - * @param scalar $prevToken |
|
11 | - * @param scalar $postToken |
|
12 | - */ |
|
13 | - public function __construct($prevToken, $postToken) |
|
14 | - { |
|
15 | - $this->message = "Quoted String found between $prevToken and $postToken"; |
|
16 | - } |
|
9 | + /** |
|
10 | + * @param scalar $prevToken |
|
11 | + * @param scalar $postToken |
|
12 | + */ |
|
13 | + public function __construct($prevToken, $postToken) |
|
14 | + { |
|
15 | + $this->message = "Quoted String found between $prevToken and $postToken"; |
|
16 | + } |
|
17 | 17 | } |
@@ -4,11 +4,11 @@ |
||
4 | 4 | |
5 | 5 | class IPV6ColonStart extends Warning |
6 | 6 | { |
7 | - const CODE = 76; |
|
7 | + const CODE = 76; |
|
8 | 8 | |
9 | - public function __construct() |
|
10 | - { |
|
11 | - $this->message = ':: found at the start of the domain literal'; |
|
12 | - $this->rfcNumber = 5322; |
|
13 | - } |
|
9 | + public function __construct() |
|
10 | + { |
|
11 | + $this->message = ':: found at the start of the domain literal'; |
|
12 | + $this->rfcNumber = 5322; |
|
13 | + } |
|
14 | 14 | } |
@@ -4,11 +4,11 @@ |
||
4 | 4 | |
5 | 5 | class DomainTooLong extends Warning |
6 | 6 | { |
7 | - const CODE = 255; |
|
7 | + const CODE = 255; |
|
8 | 8 | |
9 | - public function __construct() |
|
10 | - { |
|
11 | - $this->message = 'Domain is too long, exceeds 255 chars'; |
|
12 | - $this->rfcNumber = 5322; |
|
13 | - } |
|
9 | + public function __construct() |
|
10 | + { |
|
11 | + $this->message = 'Domain is too long, exceeds 255 chars'; |
|
12 | + $this->rfcNumber = 5322; |
|
13 | + } |
|
14 | 14 | } |
@@ -4,10 +4,10 @@ |
||
4 | 4 | |
5 | 5 | class DeprecatedComment extends Warning |
6 | 6 | { |
7 | - const CODE = 37; |
|
7 | + const CODE = 37; |
|
8 | 8 | |
9 | - public function __construct() |
|
10 | - { |
|
11 | - $this->message = 'Deprecated comments'; |
|
12 | - } |
|
9 | + public function __construct() |
|
10 | + { |
|
11 | + $this->message = 'Deprecated comments'; |
|
12 | + } |
|
13 | 13 | } |
@@ -4,11 +4,11 @@ |
||
4 | 4 | |
5 | 5 | class IPV6ColonEnd extends Warning |
6 | 6 | { |
7 | - const CODE = 77; |
|
7 | + const CODE = 77; |
|
8 | 8 | |
9 | - public function __construct() |
|
10 | - { |
|
11 | - $this->message = ':: found at the end of the domain literal'; |
|
12 | - $this->rfcNumber = 5322; |
|
13 | - } |
|
9 | + public function __construct() |
|
10 | + { |
|
11 | + $this->message = ':: found at the end of the domain literal'; |
|
12 | + $this->rfcNumber = 5322; |
|
13 | + } |
|
14 | 14 | } |
@@ -4,11 +4,11 @@ |
||
4 | 4 | |
5 | 5 | class IPV6BadChar extends Warning |
6 | 6 | { |
7 | - const CODE = 74; |
|
7 | + const CODE = 74; |
|
8 | 8 | |
9 | - public function __construct() |
|
10 | - { |
|
11 | - $this->message = 'Bad char in IPV6 domain literal'; |
|
12 | - $this->rfcNumber = 5322; |
|
13 | - } |
|
9 | + public function __construct() |
|
10 | + { |
|
11 | + $this->message = 'Bad char in IPV6 domain literal'; |
|
12 | + $this->rfcNumber = 5322; |
|
13 | + } |
|
14 | 14 | } |