GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Email   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A domain() 0 3 1
A guard() 0 6 2
A userName() 0 3 1
A createFromString() 0 3 1
A getEmailParts() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DBUnt1tled\VO\VObjects\Internet;
6
7
use DBUnt1tled\VO\Exception\InvalidVOArgumentException;
8
use DBUnt1tled\VO\VObjects\Scalar\Strings;
9
use DBUnt1tled\VO\VObjects\ValueObjectComplex;
10
use DBUnt1tled\VO\VObjects\ValueObjectInterface;
11
12
class Email extends ValueObjectComplex
13
{
14
    /**
15
     * @param mixed $value
16
     * @param mixed ...$other
17
     * @throws \ReflectionException
18
     */
19 2
    public function guard($value, ...$other): void
20
    {
21 2
        parent::guard($value);
22
        /** @var ValueObjectInterface $value*/
23 2
        if (filter_var($value->getValue(), FILTER_VALIDATE_EMAIL) === false) {
24 1
            throw new InvalidVOArgumentException('Value is not a valid e-mail address.', $value);
25
        }
26 1
    }
27
28
    /**
29
     * @return string
30
     */
31 1
    public function userName(): string
32
    {
33 1
        return $this->getEmailParts()[0];
34
    }
35
36
    /**
37
     * @return string
38
     */
39 1
    public function domain(): string
40
    {
41 1
        return $this->getEmailParts()[1];
42
    }
43
44
    /**
45
     * @param string $value
46
     * @return Email
47
     * @throws \ReflectionException
48
     */
49 2
    public static function createFromString(string $value): self
50
    {
51 2
        return new static(new Strings($value));
52
    }
53
54
    /**
55
     * @return array
56
     */
57 1
    private function getEmailParts(): array
58
    {
59 1
        return explode('@', $this->getValue());
60
    }
61
}
62