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

SpoofCheckValidation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 29
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 11 2
A getError() 0 4 1
A getWarnings() 0 4 1
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