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

SetTagDates   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 16
ccs 7
cts 9
cp 0.7778
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 10 4
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 normalizes dates in all the tags:
17
 * - drops date for the last tag
18
 * - sets dates for other tags.
19
 *
20
 * @author Andrii Vasyliev <[email protected]>
21
 */
22
class SetTagDates extends AbstractModifier
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27 2
    public function run(History $history)
28
    {
29 2
        foreach ($history->getTags() as $tag) {
30 2
            if ($tag->getName() === $history->lastTag) {
31 2
                $tag->unsetDate();
32 2
            } elseif (!$tag->getDate()) {
33
                $tag->setDate($tag->findDate());
34
            }
35 2
        }
36 2
    }
37
}
38