GitLog::setCommitterDate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
// src/VersionControl/GitCommandBundle/Entity/GitLog.php
3
4
/*
5
 * This file is part of the GitCommandBundle package.
6
 *
7
 * (c) Paul Schweppe <[email protected]>
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 VersionControl\GitCommandBundle\Entity;
14
15
/**
16
 * Useful options for git log --pretty=format Option    Description of Output.
17
 *
18
 * %H Commit hash
19
 * %h Abbreviated commit hash
20
 * %T Tree hash
21
 * %t Abbreviated tree hash
22
 * %P Parent hashes
23
 * %p Abbreviated parent hashes
24
 * %an Author name
25
 * %ae Author e-mail
26
 * %ad Author date (format respects the --date=option)
27
 * %ar Author date, relative
28
 * %cn Committer name
29
 * %ce Committer email
30
 * %cd Committer date
31
 * %cr Committer date, relative
32
 * %s Subject
33
 *
34
 * You may be wondering what the difference is between author and committer. The author is the person who originally
35
 * wrote the work, whereas the committer is the person who last applied the work. So, if you send in a patch to a
36
 * project and one of the core members
37
 * applies the patch, both of you get credit – you as the author, and the core member as the committer.
38
 *
39
 * @author Paul Schweppe <[email protected]>
40
 */
41
class GitLog
42
{
43
    /**
44
     * Commit hash.
45
     *
46
     * @var string
47
     */
48
    protected $hash;
49
50
    /**
51
     * Abbreviated commit hash.
52
     *
53
     * @var string
54
     */
55
    protected $abbrHash;
56
57
    /**
58
     * Tree hash.
59
     *
60
     * @var string
61
     */
62
    protected $treeHash;
63
64
    /**
65
     * Abbreviated tree hash.
66
     *
67
     * @var string
68
     */
69
    protected $abbrTreeHash;
70
71
    /**
72
     * Parent hashes.
73
     *
74
     * @var string
75
     */
76
    protected $parentHashes;
77
78
    /**
79
     * Abbreviated parent hashes.
80
     *
81
     * @var string
82
     */
83
    protected $abbrParentHashes;
84
85
    /**
86
     * Author name.
87
     *
88
     * @var string
89
     */
90
    protected $authorName;
91
92
    /**
93
     * Author e-mail.
94
     *
95
     * @var string
96
     */
97
    protected $authorEmail;
98
99
    /**
100
     * Author date (format respects the --date=option).
101
     *
102
     * @var string
103
     */
104
    protected $authorDate;
105
106
    /**
107
     * Author date, relative.
108
     *
109
     * @var string
110
     */
111
    protected $authorRelative;
112
113
    /**
114
     * Committer name.
115
     *
116
     * @var string
117
     */
118
    protected $committerName;
119
120
    /**
121
     * Committer email.
122
     *
123
     * @var string
124
     */
125
    protected $committerEmail;
126
127
    /**
128
     * Committer date.
129
     *
130
     * @var string
131
     */
132
    protected $committerDate;
133
134
    /**
135
     * Committer date, relative.
136
     *
137
     * @var string
138
     */
139
    protected $committerDateRelative;
140
141
    /**
142
     * Subject.
143
     *
144
     * @var string
145
     */
146
    protected $subject;
147
148
    /**
149
     * File name. Used only on single log entires.
150
     *
151
     * @var string
152
     */
153
    protected $fileName;
154
155
    public function __construct($line)
156
    {
157
        $logData = explode('|', $line);
158
        if (count($logData) >= 15) {
159
            $this->setHash(trim($logData[0]));
160
            $this->setAbbrHash(trim($logData[1]));
161
            $this->setTreeHash(trim($logData[2]));
162
            $this->setAbbrTreeHash(trim($logData[3]));
163
            $this->setParentHashes(trim($logData[4]));
164
            $this->setAbbrParentHashes(trim($logData[5]));
165
            $this->setAuthorName(trim($logData[6]));
166
            $this->setAuthorEmail(trim($logData[7]));
167
            $this->setAuthorDate(trim($logData[8]));
168
            $this->setAuthorRelative(trim($logData[9]));
169
            $this->setCommitterName(trim($logData[10]));
170
            $this->setCommitterEmail(trim($logData[11]));
171
            $this->setCommitterDate(trim($logData[12]));
172
            $this->setCommitterDateRelative(trim($logData[13]));
173
            $this->setSubject(trim($logData[14]));
174
        }
175
    }
176
177
    public function getHash(): string
178
    {
179
        return $this->hash;
180
    }
181
182
    public function getAbbrHash(): string
183
    {
184
        return $this->abbrHash;
185
    }
186
187
    public function getTreeHash(): string
188
    {
189
        return $this->treeHash;
190
    }
191
192
    public function getAbbrTreeHash(): string
193
    {
194
        return $this->abbrTreeHash;
195
    }
196
197
    public function getParentHashes(): string
198
    {
199
        return $this->parentHashes;
200
    }
201
202
    public function getAbbrParentHashes(): string
203
    {
204
        return $this->abbrParentHashes;
205
    }
206
207
    public function getAuthorName(): string
208
    {
209
        return $this->authorName;
210
    }
211
212
    public function getAuthorEmail(): string
213
    {
214
        return $this->authorEmail;
215
    }
216
217
    public function getAuthorDate(): string
218
    {
219
        return $this->authorDate;
220
    }
221
222
    public function getAuthorRelative(): string
223
    {
224
        return $this->authorRelative;
225
    }
226
227
    public function getCommitterName(): string
228
    {
229
        return $this->committerName;
230
    }
231
232
    public function getCommitterEmail(): string
233
    {
234
        return $this->committerEmail;
235
    }
236
237
    public function getCommitterDate(): string
238
    {
239
        return $this->committerDate;
240
    }
241
242
    public function getCommitterDateRelative(): string
243
    {
244
        return $this->committerDateRelative;
245
    }
246
247
    public function getSubject(): string
248
    {
249
        return $this->subject;
250
    }
251
252
    public function setHash($hash)
253
    {
254
        $this->hash = $hash;
255
256
        return $this;
257
    }
258
259
    public function setAbbrHash($abbrHash)
260
    {
261
        $this->abbrHash = $abbrHash;
262
263
        return $this;
264
    }
265
266
    public function setTreeHash($treeHash)
267
    {
268
        $this->treeHash = $treeHash;
269
270
        return $this;
271
    }
272
273
    public function setAbbrTreeHash($abbrTreeHash)
274
    {
275
        $this->abbrTreeHash = $abbrTreeHash;
276
277
        return $this;
278
    }
279
280
    public function setParentHashes($parentHashes)
281
    {
282
        $this->parentHashes = $parentHashes;
283
284
        return $this;
285
    }
286
287
    public function setAbbrParentHashes($abbrParentHashes)
288
    {
289
        $this->abbrParentHashes = $abbrParentHashes;
290
291
        return $this;
292
    }
293
294
    public function setAuthorName($authorName)
295
    {
296
        $this->authorName = $authorName;
297
298
        return $this;
299
    }
300
301
    public function setAuthorEmail($authorEmail)
302
    {
303
        $this->authorEmail = $authorEmail;
304
305
        return $this;
306
    }
307
308
    public function setAuthorDate($authorDate)
309
    {
310
        $this->authorDate = $authorDate;
311
312
        return $this;
313
    }
314
315
    public function setAuthorRelative($authorRelative)
316
    {
317
        $this->authorRelative = $authorRelative;
318
319
        return $this;
320
    }
321
322
    public function setCommitterName($committerName)
323
    {
324
        $this->committerName = $committerName;
325
326
        return $this;
327
    }
328
329
    public function setCommitterEmail($committerEmail)
330
    {
331
        $this->committerEmail = $committerEmail;
332
333
        return $this;
334
    }
335
336
    public function setCommitterDate($committerDate)
337
    {
338
        $this->committerDate = $committerDate;
339
340
        return $this;
341
    }
342
343
    public function setCommitterDateRelative($committerDateRelative)
344
    {
345
        $this->committerDateRelative = $committerDateRelative;
346
347
        return $this;
348
    }
349
350
    public function setSubject($subject)
351
    {
352
        $this->subject = $subject;
353
354
        return $this;
355
    }
356
357
    public function getFileName(): string
358
    {
359
        return $this->fileName;
360
    }
361
362
    public function setFileName($fileName)
363
    {
364
        $this->fileName = $fileName;
365
366
        return $this;
367
    }
368
}
369