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

RemoveEmptyFirstTag::run()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5.9256

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
ccs 8
cts 12
cp 0.6667
rs 8.8571
cc 5
eloc 10
nc 4
nop 1
crap 5.9256
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