Email::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace PersonalGalaxy\Identity\Entity\Identity;
5
6
use PersonalGalaxy\Identity\Exception\DomainException;
7
8
final class Email
9
{
10
    private $value;
11
12 21
    public function __construct(string $value)
13
    {
14 21
        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
15 1
            throw new DomainException;
16
        }
17
18 20
        $this->value = $value;
19 20
    }
20
21 4
    public function __toString(): string
22
    {
23 4
        return $this->value;
24
    }
25
}
26