Identity   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 52
rs 10
wmc 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getDate() 0 3 1
A getEmail() 0 3 1
A getName() 0 3 1
A setDate() 0 8 3
A setEmail() 0 5 1
A setName() 0 5 1
A __construct() 0 7 2
1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of Biurad opensource projects.
5
 *
6
 * @copyright 2022 Biurad Group (https://biurad.com/)
7
 * @license   https://opensource.org/licenses/BSD-3-Clause License
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Biurad\Git\Commit;
14
15
/**
16
 * User Identifier.
17
 *
18
 * @author Divine Niiquaye Ibok <[email protected]>
19
 */
20
class Identity
21
{
22
    private string $name, $email;
23
    private ?\DateTimeInterface $date = null;
24
25
    public function __construct(string $name, string $email, \DateTimeInterface|string $date = null)
26
    {
27
        $this->name = $name;
28
        $this->email = $email;
29
30
        if (null !== $date) {
31
            $this->setDate($date);
32
        }
33
    }
34
35
    public function setName(string $name): self
36
    {
37
        $this->name = $name;
38
39
        return $this;
40
    }
41
42
    public function getName(): string
43
    {
44
        return $this->name;
45
    }
46
47
    public function setEmail(string $email): self
48
    {
49
        $this->email = $email;
50
51
        return $this;
52
    }
53
54
    public function getEmail(): string
55
    {
56
        return $this->email;
57
    }
58
59
    public function setDate(\DateTimeInterface|string $date): self
60
    {
61
        if (\is_string($date)) {
62
            $date = new \DateTimeImmutable(\is_numeric($date) ? '@'.$date : $date);
63
        }
64
        $this->date = $date;
65
66
        return $this;
67
    }
68
69
    public function getDate(): ?\DateTimeInterface
70
    {
71
        return $this->date;
72
    }
73
}
74