summaryrefslogtreecommitdiff
path: root/vendor/swiftmailer/classes/Swift/Validate.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/swiftmailer/classes/Swift/Validate.php')
-rw-r--r--vendor/swiftmailer/classes/Swift/Validate.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/swiftmailer/classes/Swift/Validate.php b/vendor/swiftmailer/classes/Swift/Validate.php
new file mode 100644
index 00000000..2a338bdc
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Validate.php
@@ -0,0 +1,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
+ );
+ }
+}