vendor/swiftmailer/lib/classes/Swift/Validate.php
changeset 0 7f95f8617b0b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/swiftmailer/lib/classes/Swift/Validate.php	Sat Sep 24 15:40:41 2011 +0200
@@ -0,0 +1,38 @@
+<?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
+ * @package Swift
+ * @author Xavier De Cock <xdecock@gmail.com>
+ */
+class Swift_Validate
+{
+  /**
+   * Grammar Object
+   * @var Swift_Mime_Grammar
+   */
+  private static $grammar = null;
+  
+  /**
+   * Checks if an email matches the current grammars
+   * @param string $email
+   */
+  public static function email($email)
+  {
+    if (self::$grammar===null)
+    {
+      self::$grammar = Swift_DependencyContainer::getInstance()
+        ->lookup('mime.grammar');
+    }
+    return preg_match(
+        '/^' . self::$grammar->getDefinition('addr-spec') . '$/D',
+        $email
+      );
+  }
+}
\ No newline at end of file