Author::getEmailAddress()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Gitilicious\GitClient\Git;
4
5
class Author
6
{
7
    private $name;
8
9
    private $emailAddress;
10
11 4
    public function __construct(string $name, string $emailAddress)
12
    {
13 4
        if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
14 1
            throw new \RuntimeException(sprintf('The provided email address `%s` is not valid.', $emailAddress));
15
        }
16
17 3
        $this->name         = $name;
18 3
        $this->emailAddress = $emailAddress;
19 3
    }
20
21 1
    public function getName(): string
22
    {
23 1
        return $this->name;
24
    }
25
26 1
    public function getEmailAddress(): string
27
    {
28 1
        return $this->emailAddress;
29
    }
30
31 1
    public function getFormatted(): string
32
    {
33 1
        return sprintf('%s <%s>', $this->name, $this->emailAddress);
34
    }
35
}
36