EmailAddress   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 4
A value() 0 4 1
1
<?php
2
3
namespace Equip\ValueObject;
4
5
use InvalidArgumentException;
6
7
class EmailAddress
8
{
9
    /**
10
     * @var string|null
11
     */
12
    private $email;
13
14 6
    public function __construct($email, $is_required = true)
15
    {
16 6
        static $empty_values = [null, ''];
17
18 6
        if (!$is_required && in_array($email, $empty_values, true)) {
19 1
            $email = null;
20 6
        } elseif (filter_var($email, \FILTER_VALIDATE_EMAIL) === false) {
21 4
            throw new InvalidArgumentException('Value must be an email address');
22
        }
23
24 2
        $this->email = $email;
25 2
    }
26
27 2
    public function value()
28
    {
29 2
        return $this->email;
30
    }
31
}
32