Commit   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 138
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 21
c 1
b 0
f 0
dl 0
loc 138
ccs 24
cts 24
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuthor() 0 3 1
A hasNames() 0 3 1
A getSubject() 0 3 1
A getDate() 0 3 1
A getNames() 0 3 1
A getHash() 0 3 1
A __construct() 0 14 1
A getDescription() 0 3 1
A getBody() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of SebastianFeldmann\Git.
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace SebastianFeldmann\Git\Log;
13
14
/**
15
 * Class Commit
16
 *
17
 * @package SebastianFeldmann\Git
18
 * @author  Sebastian Feldmann <[email protected]>
19
 * @link    https://github.com/sebastianfeldmann/git
20
 * @since   Class available since Release 1.2.0
21
 */
22
class Commit
23
{
24
    /**
25
     * @var string
26
     */
27
    private $hash;
28
29
    /**
30
     * @var array
31
     */
32
    private $names;
33
34
    /**
35
     * @var string
36
     */
37
    private $subject;
38
39
    /**
40
     * @var string
41
     */
42
    private $body;
43
44
    /**
45
     * @var \DateTimeImmutable
46
     */
47
    private $date;
48
49
    /**
50
     * @var string
51
     */
52
    private $author;
53
54
    /**
55
     * Commit constructor.
56
     *
57
     * @param string             $hash
58
     * @param array              $names
59
     * @param string             $subject
60
     * @param string             $body
61
     * @param \DateTimeImmutable $date
62 5
     * @param string             $author
63
     */
64
    public function __construct(
65
        string $hash,
66
        array $names,
67
        string $subject,
68
        string $body,
69
        \DateTimeImmutable $date,
70
        string $author
71 5
    ) {
72 5
        $this->hash    = $hash;
73 5
        $this->names   = $names;
74 5
        $this->subject = $subject;
75 5
        $this->body    = $body;
76 5
        $this->date    = $date;
77 5
        $this->author  = $author;
78
    }
79
80
    /**
81
     * Hash getter.
82
     *
83
     * @return string
84 2
     */
85
    public function getHash(): string
86 2
    {
87
        return $this->hash;
88
    }
89
90
    /**
91
     * Does the commit have names.
92
     *
93
     * @return bool
94 2
     */
95
    public function hasNames(): bool
96 2
    {
97
        return !empty($this->names);
98
    }
99
100
    /**
101
     * Names getter.
102
     *
103
     * @return array
104 2
     */
105
    public function getNames(): array
106 2
    {
107
        return $this->names;
108
    }
109
110
    /**
111
     * Description getter.
112
     *
113
     * @deprecated
114
     *
115
     * @return string
116 1
     */
117
    public function getDescription(): string
118 1
    {
119
        return $this->getSubject();
120
    }
121
122
    /**
123
     * Subject getter.
124
     *
125
     * @return string
126 2
     */
127
    public function getSubject(): string
128 2
    {
129
        return $this->subject;
130
    }
131
132
    /**
133
     * Body getter.
134
     *
135
     * @return string
136 2
     */
137
    public function getBody(): string
138 2
    {
139
        return $this->body;
140
    }
141
142
    /**
143
     * Date getter.
144
     *
145
     * @return \DateTimeImmutable
146 1
     */
147
    public function getDate(): \DateTimeImmutable
148 1
    {
149
        return $this->date;
150
    }
151
152
    /**
153
     * Author getter.
154
     *
155
     * @return string
156 4
     */
157
    public function getAuthor(): string
158 4
    {
159
        return $this->author;
160
    }
161
}
162