Skip to content

Commit 6fbc67e

Browse files
authored
Merge pull request #20 from daveearley/more-php7.4-updates
php 7.4 updates
2 parents 6383ec9 + 36fff39 commit 6fbc67e

File tree

4 files changed

+8
-40
lines changed

4 files changed

+8
-40
lines changed

src/EmailValidator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getValidationResults(): ValidationResults
6666
return $this->validationResults;
6767
}
6868

69-
public function runValidation()
69+
public function runValidation(): void
7070
{
7171
foreach ($this->registeredValidators as $validator) {
7272
$this->validationResults->addResult($validator->getValidatorName(), $validator->getResultResponse());

src/EmailValidatorFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class EmailValidatorFactory
1717
{
1818
/** @var Validator[] */
19-
private static array $defaultValidators = [
19+
protected static array $defaultValidators = [
2020
ValidFormatValidator::class,
2121
MxRecordsValidator::class,
2222
MisspelledEmailValidator::class,

src/Validations/MisspelledEmailValidator.php

+2-14
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99
*/
1010
class MisspelledEmailValidator extends Validator implements ValidatorInterface
1111
{
12-
const MINIMUM_WORD_DISTANCE_DOMAIN = 2;
13-
const MINIMUM_WORD_DISTANCE_TLD = 1;
12+
private const MINIMUM_WORD_DISTANCE_DOMAIN = 2;
13+
private const MINIMUM_WORD_DISTANCE_TLD = 1;
1414

15-
/**
16-
* @return string
17-
*/
1815
public function getValidatorName(): string
1916
{
2017
return 'possible_email_correction'; // @codeCoverageIgnore
2118
}
2219

23-
/**
24-
* @return string
25-
*/
2620
public function getResultResponse(): string
2721
{
2822
if (!$this->getEmailAddress()->isValidEmailAddressFormat()) {
@@ -76,12 +70,6 @@ private function findDomainSuggestion()
7670
return $domain === $possibleMatch ? null : $possibleMatch;
7771
}
7872

79-
/**
80-
* @param string $stringToCheck
81-
* @param array $wordsToCheck
82-
* @param int $minimumDistance
83-
* @return string|bool
84-
*/
8573
private function findClosestWord(string $stringToCheck, array $wordsToCheck, int $minimumDistance): string
8674
{
8775
if (in_array($stringToCheck, $wordsToCheck)) {

src/Validations/Validator.php

+4-24
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,33 @@
1010

1111
abstract class Validator
1212
{
13-
/** @var EmailAddress */
14-
private $emailAddress;
13+
private ?EmailAddress $emailAddress;
1514

16-
/** @var EmailDataProvider|null */
17-
private $emailDataProvider;
15+
private ?EmailDataProvider $emailDataProvider;
1816

19-
/**
20-
* @param EmailAddress $emailAddress
21-
* @param EmailDataProviderInterface $emailDataProvider
22-
*/
2317
public function __construct(EmailAddress $emailAddress = null, EmailDataProviderInterface $emailDataProvider = null)
2418
{
2519
$this->emailAddress = $emailAddress;
2620
$this->emailDataProvider = $emailDataProvider;
2721
}
2822

29-
/**
30-
* @return EmailAddress
31-
*/
3223
public function getEmailAddress(): EmailAddress
3324
{
3425
return $this->emailAddress;
3526
}
3627

37-
/**
38-
* @param EmailAddress $emailAddress
39-
* @return $this
40-
*/
41-
public function setEmailAddress(EmailAddress $emailAddress)
28+
public function setEmailAddress(EmailAddress $emailAddress): Validator
4229
{
4330
$this->emailAddress = $emailAddress;
4431
return $this;
4532
}
4633

47-
/**
48-
* @return EmailDataProviderInterface
49-
*/
5034
public function getEmailDataProvider(): EmailDataProviderInterface
5135
{
5236
return $this->emailDataProvider;
5337
}
5438

55-
/**
56-
* @param EmailDataProviderInterface|null $emailDataProvider
57-
* @return $this
58-
*/
59-
public function setEmailDataProvider(EmailDataProviderInterface $emailDataProvider)
39+
public function setEmailDataProvider(EmailDataProviderInterface $emailDataProvider): Validator
6040
{
6141
$this->emailDataProvider = $emailDataProvider;
6242
return $this;

0 commit comments

Comments
 (0)