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

EmailValidatorFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 10
ccs 0
cts 6
cp 0
crap 6
rs 10
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
}