Skip to content

Commit

Permalink
formatting and cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 7, 2020
1 parent 1a9d6a7 commit 43a1ed1
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/Illuminate/Validation/Concerns/FilterEmailValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,31 @@
class FilterEmailValidation implements EmailValidation
{
/**
* @var int
* The flags to pass to the filter_var function.
*
* @var int|null
*/
protected $flags;

/**
* Create a new instance which allows any unicode characters in local-part.
* Create a new validation instance.
*
* @return static
* @param int $flags
* @return void
*/
public static function unicode()
public function __construct($flags = null)
{
return new static(FILTER_FLAG_EMAIL_UNICODE);
$this->flags = $flags;
}

/**
* FilterEmailValidation constructor.
* Create a new instance which allows any unicode characters in local-part.
*
* @param int $flags
* @return static
*/
public function __construct($flags = 0)
public static function unicode()
{
$this->flags = $flags;
return new static(FILTER_FLAG_EMAIL_UNICODE);
}

/**
Expand All @@ -41,7 +44,9 @@ public function __construct($flags = 0)
*/
public function isValid($email, EmailLexer $emailLexer)
{
return filter_var($email, FILTER_VALIDATE_EMAIL, $this->flags) !== false;
return is_null($this->flags)
? filter_var($email, FILTER_VALIDATE_EMAIL) !== false
: filter_var($email, FILTER_VALIDATE_EMAIL, $this->flags) !== false;
}

/**
Expand Down

0 comments on commit 43a1ed1

Please sign in to comment.