Author::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
crap 2
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