Test Failed
Push — master ( cf5cf8...b2d113 )
by Rob
04:15
created

EmailNameWrapper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setLocalName() 0 4 1
A process() 0 32 4
1
<?php
2
3
namespace devtoolboxuk\cerberus\Wrappers;
4
5
class EmailNameWrapper extends Base
6
{
7
8
    public function process()
9
    {
10
        $this->initWrapper($this->setLocalName());
11
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
12
13
        list($name, $email) = explode('|', $this->getReference());
14
15
        $name = trim($name);
16
        $emailName = '';
17
        $sanitise = $this->soteria->sanitise();
18
        $sanitise->disinfect($email, 'email');
19
20
        if ($sanitise->result()->isValid()) {
21
            $email = explode("@",$sanitise->result()->getOutput());
22
            $email_characters = ['.','+','-','_'];
23
            $emailName = str_replace($email_characters,' ',strtolower($email[0]));
24
        }
25
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
26
27
        $sanitise = $this->soteria->sanitise();
28
        $sanitise->disinfect($name);
29
30
        if ($sanitise->result()->isValid()) {
31
            $name = strtolower($sanitise->result()->getOutput());
32
        }
33
34
        if (strcasecmp($name, $emailName) == 0) {
35
            $this->setScore($this->getRealScore());
36
            $this->setResult();
37
        } else {
38
            $this->setScore($this->getFailScore());
39
            $this->setResult();
40
        }
41
    }
42
43
    private function setLocalName()
44
    {
45
        $name = str_replace(__NAMESPACE__ . '\\', '', __CLASS__);
46
        return str_replace('Wrapper', '', $name);
47
    }
48
49
}