File tree Expand file tree Collapse file tree
src/Illuminate/Validation/Concerns Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88class FilterEmailValidation implements EmailValidation
99{
1010 /**
11- * @var int
11+ * The flags to pass to the filter_var function.
12+ *
13+ * @var int|null
1214 */
1315 protected $ flags ;
1416
1517 /**
16- * Create a new instance which allows any unicode characters in local-part .
18+ * Create a new validation instance .
1719 *
18- * @return static
20+ * @param int $flags
21+ * @return void
1922 */
20- public static function unicode ( )
23+ public function __construct ( $ flags = null )
2124 {
22- return new static ( FILTER_FLAG_EMAIL_UNICODE ) ;
25+ $ this -> flags = $ flags ;
2326 }
2427
2528 /**
26- * FilterEmailValidation constructor .
29+ * Create a new instance which allows any unicode characters in local-part .
2730 *
28- * @param int $flags
31+ * @return static
2932 */
30- public function __construct ( $ flags = 0 )
33+ public static function unicode ( )
3134 {
32- $ this -> flags = $ flags ;
35+ return new static ( FILTER_FLAG_EMAIL_UNICODE ) ;
3336 }
3437
3538 /**
@@ -41,7 +44,9 @@ public function __construct($flags = 0)
4144 */
4245 public function isValid ($ email , EmailLexer $ emailLexer )
4346 {
44- return filter_var ($ email , FILTER_VALIDATE_EMAIL , $ this ->flags ) !== false ;
47+ return is_null ($ this ->flags )
48+ ? filter_var ($ email , FILTER_VALIDATE_EMAIL ) !== false
49+ : filter_var ($ email , FILTER_VALIDATE_EMAIL , $ this ->flags ) !== false ;
4550 }
4651
4752 /**
You can’t perform that action at this time.
0 commit comments