|
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
|
|
|
|
|
12
|
|
|
list($name, $email) = explode('|', $this->getReference()); |
|
13
|
|
|
|
|
14
|
|
|
$name = trim($name); |
|
15
|
|
|
$emailName = ''; |
|
16
|
|
|
$sanitise = $this->soteria->sanitise(); |
|
17
|
|
|
$sanitise->disinfect($email, 'email'); |
|
18
|
|
|
|
|
19
|
|
|
if ($sanitise->result()->isValid()) { |
|
20
|
|
|
$email = explode("@", $sanitise->result()->getOutput()); |
|
21
|
|
|
$email_characters = ['.', '+', '-', '_']; |
|
22
|
|
|
$emailName = str_replace($email_characters, ' ', strtolower($email[0])); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
$sanitise = $this->soteria->sanitise(); |
|
26
|
|
|
$sanitise->disinfect($name); |
|
27
|
|
|
|
|
28
|
|
|
if ($sanitise->result()->isValid()) { |
|
29
|
|
|
$name = strtolower($sanitise->result()->getOutput()); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
if (strcasecmp($name, $emailName) == 0) { |
|
33
|
|
|
$this->setScore($this->getRealScore()); |
|
34
|
|
|
$this->setResult(); |
|
35
|
|
|
} else { |
|
36
|
|
|
$this->setScore($this->getFailScore()); |
|
37
|
|
|
$this->setResult(); |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
private function setLocalName() |
|
42
|
|
|
{ |
|
43
|
|
|
$name = str_replace(__NAMESPACE__ . '\\', '', __CLASS__); |
|
44
|
|
|
return str_replace('Wrapper', '', $name); |
|
45
|
|
|
} |
|
46
|
|
|
} |