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