blob: 2a338bdc7419fb515f4e6d9e4ca97f032e8a5fba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<?php
/*
* This file is part of SwiftMailer.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Utility Class allowing users to simply check expressions again Swift Grammar.
*
* @author Xavier De Cock <xdecock@gmail.com>
*/
class Swift_Validate
{
/**
* Grammar Object
*
* @var Swift_Mime_Grammar
*/
private static $grammar = null;
/**
* Checks if an e-mail address matches the current grammars.
*
* @param string $email
*
* @return bool
*/
public static function email($email)
{
if (self::$grammar===null) {
self::$grammar = Swift_DependencyContainer::getInstance()
->lookup('mime.grammar');
}
return (bool) preg_match(
'/^' . self::$grammar->getDefinition('addr-spec') . '$/D',
$email
);
}
}
|