Completed
Push — master ( 11a376...8d38b3 )
by Andrii
03:54
created

RemoveEmptyFirstTag   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 21
ccs 8
cts 12
cp 0.6667
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 15 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\modifiers;
12
13
use hiqdev\chkipper\history\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