Completed
Push — master ( 8d38b3...065629 )
by Andrii
02:12
created

MarkdownRenderer::renderNote()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 16
ccs 0
cts 15
cp 0
rs 9.2
cc 4
eloc 10
nc 5
nop 1
crap 20
1
<?php
2
/**
3
 * Changelog keeper
4
 *
5
 * @link      https://github.com/hiqdev/chkipper
6
 * @package   chkipper
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\chkipper\lib\changelog;
12
13
use hiqdev\chkipper\lib\Note;
14
15
/**
16
 * Markdown changelog renderer.
17
 *
18
 * @author Andrii Vasyliev <[email protected]>
19
 */
20
class MarkdownRenderer extends \hiqdev\chkipper\lib\renderers\MarkdownRenderer
21
{
22
    protected $normalization = Normalization::class;
23
24
    public function renderNote(Note $note)
25
    {
26
        $str = $this->renderNoteHead($note);
27
        if (!$str) {
28
            return;
29
        }
30
        $authors = [];
31
        foreach ($note->getCommits() as $commit) {
32
            $authors[$commit->getAuthor()] = '[' . $commit->getAuthor() . ']';
33
        }
34
        if ($authors) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $authors of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
35
            $str .= ' (' . implode(', ', $authors) . ')';
36
        }
37
38
        return $str;
39
    }
40
}
41