Completed
Push — master ( ef682c...1e33b0 )
by Pieter
02:53
created

Author   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 31
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getName() 0 4 1
A getEmailAddress() 0 4 1
A getFormatted() 0 4 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