diff --git a/src/EmailValidator.php b/src/EmailValidator.php index 41e9f1c..146a0f8 100644 --- a/src/EmailValidator.php +++ b/src/EmailValidator.php @@ -66,7 +66,7 @@ public function getValidationResults(): ValidationResults return $this->validationResults; } - public function runValidation() + public function runValidation(): void { foreach ($this->registeredValidators as $validator) { $this->validationResults->addResult($validator->getValidatorName(), $validator->getResultResponse()); diff --git a/src/EmailValidatorFactory.php b/src/EmailValidatorFactory.php index fcac400..27a7b69 100644 --- a/src/EmailValidatorFactory.php +++ b/src/EmailValidatorFactory.php @@ -16,7 +16,7 @@ class EmailValidatorFactory { /** @var Validator[] */ - private static array $defaultValidators = [ + protected static array $defaultValidators = [ ValidFormatValidator::class, MxRecordsValidator::class, MisspelledEmailValidator::class, diff --git a/src/Validations/MisspelledEmailValidator.php b/src/Validations/MisspelledEmailValidator.php index 4ffc34a..1ba7491 100644 --- a/src/Validations/MisspelledEmailValidator.php +++ b/src/Validations/MisspelledEmailValidator.php @@ -9,20 +9,14 @@ */ class MisspelledEmailValidator extends Validator implements ValidatorInterface { - const MINIMUM_WORD_DISTANCE_DOMAIN = 2; - const MINIMUM_WORD_DISTANCE_TLD = 1; + private const MINIMUM_WORD_DISTANCE_DOMAIN = 2; + private const MINIMUM_WORD_DISTANCE_TLD = 1; - /** - * @return string - */ public function getValidatorName(): string { return 'possible_email_correction'; // @codeCoverageIgnore } - /** - * @return string - */ public function getResultResponse(): string { if (!$this->getEmailAddress()->isValidEmailAddressFormat()) { @@ -76,12 +70,6 @@ private function findDomainSuggestion() return $domain === $possibleMatch ? null : $possibleMatch; } - /** - * @param string $stringToCheck - * @param array $wordsToCheck - * @param int $minimumDistance - * @return string|bool - */ private function findClosestWord(string $stringToCheck, array $wordsToCheck, int $minimumDistance): string { if (in_array($stringToCheck, $wordsToCheck)) { diff --git a/src/Validations/Validator.php b/src/Validations/Validator.php index 976a15d..080a036 100644 --- a/src/Validations/Validator.php +++ b/src/Validations/Validator.php @@ -10,53 +10,33 @@ abstract class Validator { - /** @var EmailAddress */ - private $emailAddress; + private ?EmailAddress $emailAddress; - /** @var EmailDataProvider|null */ - private $emailDataProvider; + private ?EmailDataProvider $emailDataProvider; - /** - * @param EmailAddress $emailAddress - * @param EmailDataProviderInterface $emailDataProvider - */ public function __construct(EmailAddress $emailAddress = null, EmailDataProviderInterface $emailDataProvider = null) { $this->emailAddress = $emailAddress; $this->emailDataProvider = $emailDataProvider; } - /** - * @return EmailAddress - */ public function getEmailAddress(): EmailAddress { return $this->emailAddress; } - /** - * @param EmailAddress $emailAddress - * @return $this - */ - public function setEmailAddress(EmailAddress $emailAddress) + public function setEmailAddress(EmailAddress $emailAddress): Validator { $this->emailAddress = $emailAddress; return $this; } - /** - * @return EmailDataProviderInterface - */ public function getEmailDataProvider(): EmailDataProviderInterface { return $this->emailDataProvider; } - /** - * @param EmailDataProviderInterface|null $emailDataProvider - * @return $this - */ - public function setEmailDataProvider(EmailDataProviderInterface $emailDataProvider) + public function setEmailDataProvider(EmailDataProviderInterface $emailDataProvider): Validator { $this->emailDataProvider = $emailDataProvider; return $this;