Passed
Pull Request — 3.x (#335)
by
unknown
07:20
created

EmailValidatorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 25
ccs 0
cts 6
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Egulias\EmailValidator;
6
7
use Egulias\EmailValidator\Validation\DNSCheckValidation;
8
use Egulias\EmailValidator\Validation\DNSGetRecordWrapper;
9
use Egulias\EmailValidator\Validation\MessageIDValidation;
10
use Egulias\EmailValidator\Validation\NoRFCWarningsValidation;
11
use Egulias\EmailValidator\Validation\RFCValidation;
12
13
class EmailValidatorFactory
14
{
15
    /** @var [] */
0 ignored issues
show
Documentation Bug introduced by
The doc comment [] at position 0 could not be parsed: Unknown type name '[' at position 0 in [].
Loading history...
16
    protected static array $defaultValidators = [
17
        RFCValidation::class,
18
        NoRFCWarningsValidation::class,
19
        MessageIDValidation::class,
20
        DNSGetRecordWrapper::class,
21
        DNSCheckValidation::class
22
    ];
23
    
24
    /**
25
     * @param string $emailAddress
26
     * @return array
27
     */
28
    public static function create(string $emailAddress): array
29
    {
30
        $validator = new EmailValidator();
31
        $result = [];
32
33
        foreach (self::$defaultValidators as $key => $val) {
34
            $result[get_class(new $val)] = $validator->isValid($emailAddress, new $val);
35
        }
36
37
        return $result;
38
    }
39
}