Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/EmailChecker/Constraints/NotThrowawayEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ class NotThrowawayEmail extends Constraint
*/
public $message = 'The domain associated with this email is not valid.';

/**
* @param array<string, mixed>|string|null $message
*/
public function __construct(
$options = null,
array|string|null $message = null,
?array $groups = null,
$payload = null,
?string $message = null,
mixed $payload = null,
) {
$options = [];
if (\is_array($message)) {
$options = $message;
$message = $options['message'] ?? null;
}

parent::__construct($options, $groups, $payload);

$this->message = $message ?? $this->message;
Expand Down
6 changes: 1 addition & 5 deletions src/EmailChecker/Constraints/NotThrowawayEmailValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace EmailChecker\Constraints;

use EmailChecker\EmailChecker;
use ReturnTypeWillChange;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
Expand All @@ -34,11 +33,8 @@ public function __construct(?EmailChecker $emailChecker = null)

/**
* @param mixed $value
*
* @return void
*/
#[ReturnTypeWillChange]
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof NotThrowawayEmail) {
throw new UnexpectedTypeException($constraint, NotThrowawayEmail::class);
Expand Down