Passed
Push — master ( 0db193...9534e6 )
by Rob
04:00
created

DisposableEmail::setLocalName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace devtoolboxuk\cerberus\Wrappers;
4
5
use devtoolboxuk\lists\ListService;
6
7
class DisposableEmail extends Base
8
{
9
10
    private $domain;
11
12
    public function process()
13
    {
14
        $this->initWrapper($this->setLocalName());
15
16
        $this->getDomain();
17
        $this->validateDisposableEmail();
18
    }
19
20
    private function setLocalName()
21
    {
22
        $name = str_replace(__NAMESPACE__ . '\\', '', __CLASS__);
23
        return str_replace('Wrapper', '', $name);
24
    }
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
}