Completed
Pull Request — master (#231)
by Graham
05:40 queued 02:42
created

SpoofCheckValidation::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0625
1
<?php
2
3
namespace Egulias\EmailValidator\Validation;
4
5
use Egulias\EmailValidator\EmailLexer;
6
use Egulias\EmailValidator\Exception\InvalidEmail;
7
use Egulias\EmailValidator\Validation\Error\SpoofEmail;
8
use \Spoofchecker;
9
10
class SpoofCheckValidation implements EmailValidation
11
{
12
    /**
13
     * @var InvalidEmail
14
     */
15
    private $error;
16
17 1
    public function isValid($email, EmailLexer $emailLexer)
18
    {
19 1
        $checker = new Spoofchecker();
20 1
        $checker->setChecks(Spoofchecker::SINGLE_SCRIPT);
21
22 1
        if ($checker->isSuspicious($email)) {
23 1
            $this->error = new SpoofEmail();
24 1
        }
25
26 1
        return $this->error === null;
27
    }
28
29
    public function getError()
30
    {
31
        return $this->error;
32
    }
33
34
    public function getWarnings()
35
    {
36
        return [];
37
    }
38
}
39