Skip to content

Commit 43a1ed1

Browse files
committed
formatting and cleaning
1 parent 1a9d6a7 commit 43a1ed1

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/Illuminate/Validation/Concerns/FilterEmailValidation.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@
88
class 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
/**

0 commit comments

Comments
 (0)