Completed
Push — master ( 56ea51...11e69c )
by Rob
04:30 queued 10s
created

DisposableEmailWrapper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setLocalName() 0 4 1
A process() 0 6 1
A validateDisposableEmail() 0 7 2
A getDomain() 0 4 1
1
<?php
2
3
namespace devtoolboxuk\cerberus\Wrappers;
4
5
use devtoolboxuk\lists\ListService;
6
7
class DisposableEmailWrapper extends Wrapper
8
{
9
10 2
    private $domain;
11
12 2
    public function process()
13
    {
14 2
        $this->initWrapper($this->setLocalName());
15 2
16 1
        $this->getDomain();
17 1
        $this->validateDisposableEmail();
18
    }
19 2
20
    private function setLocalName()
21 2
    {
22
        $name = str_replace(__NAMESPACE__ . '\\', '', __CLASS__);
23 2
        return str_replace('Wrapper', '', $name);
24 2
    }
25
26
    private function getDomain()
27
    {
28
        $email = $this->getReference();
29
        $this->domain = substr($email, strpos($email, '@') + 1);
30
    }
31
32
    private function validateDisposableEmail()
33
    {
34
        $listService = new ListService();
35
36
        if ($listService->findInArray('throwawaydomains', $this->domain)) {
37
            $this->setScore($this->getRealScore());
38
            $this->setResult();
39
        }
40
    }
41
}