RemoveEmptyFirstTag   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 19
ccs 8
cts 11
cp 0.7272
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 14 5
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\modifiers;
12
13
use hiqdev\chkipper\lib\History;
14
15
/**
16
 * Modifier that removes first tag if it is empty.
17
 * Empty tag has no notes and no commits.
18
 *
19
 * @author Andrii Vasyliev <[email protected]>
20
 */
21
class RemoveEmptyFirstTag extends AbstractModifier
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 2
    public function run(History $history)
27
    {
28 2
        $tag = $history->getFirstTag();
29 2
        $notes = $tag->getNotes();
30 2
        if (count($notes) > 1) {
31
            return;
32
        }
33 2
        if (count($notes) > 0) {
34 2
            $note = reset($notes);
35 2
            if ($note->getNote() || count($note->getCommits()) > 0) {
36 2
                return;
37
            }
38
        }
39
        $history->removeTag($tag->getName());
40
    }
41
}
42