Completed
Push — master ( 8efc54...79b269 )
by Sebastian
02:40
created

Commit::getSubject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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