Skip to content

Commit 31d33af

Browse files
committed
Optimize method GitChangeLog::build()
The method build uses an else expression. Else clauses are basically not necessary. You can simplify the code by not using them.
1 parent f8e2449 commit 31d33af

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/GitChangeLog.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,13 @@ public function build(): void
267267
// Build changelog.
268268
foreach ($commitData as $tag => &$data) {
269269
// Add tag header and date.
270+
$tagData = [$tag, $data['date']];
270271
if ($tag == 'HEAD') {
271-
$tag = $this->options['headSubject'];
272-
$logContent .= str_replace(['{tag}', '{date}'], [$tag, $this->options['nextTagDate']],
273-
$this->formatTag);
274-
} else {
275-
$logContent .= str_replace(['{tag}', '{date}'], [$tag, $data['date']], $this->formatTag);
272+
$tagData = [$this->options['headSubject'], $this->options['nextTagDate']];
276273
}
277274

275+
$logContent .= str_replace(['{tag}', '{date}'], $tagData, $this->formatTag);
276+
278277
// No subjects present for this tag.
279278
if (empty($data['subjects'])) {
280279
$subject = $this->options['noChangesMessage'];

0 commit comments

Comments
 (0)