Email   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 13
c 1
b 0
f 1
dl 0
loc 25
ccs 13
cts 13
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A mask() 0 19 3
1
<?php
2
3
namespace Nip\Utility;
4
5
/**
6
 * Class Email
7
 * @package Nip\Utility
8
 */
9
class Email
10
{
11
    /**
12
     * @param $email
13
     * @return mixed
14
     */
15 5
    public static function mask($email)
16
    {
17 5
        if (strpos($email, '@') === false) {
18 1
            return Str::mask($email, 1);
19
        }
20
21 4
        list($username, $domain) = explode("@", $email);
22
23 4
        $parts[] = Str::mask($username, 1);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$parts was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parts = array(); before regardless.
Loading history...
24 4
        $parts[] = '@';
25
26 4
        $domainParts = explode('.', $domain);
27 4
        $lastPart = array_pop($domainParts);
28 4
        foreach ($domainParts as $part) {
29 3
            $parts[] = Str::mask($part, 1);
30 3
            $parts[] = '.';
31
        }
32 4
        $parts[] = $lastPart;
33 4
        return implode('', $parts);
34
    }
35
}
36