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

SetTagDates::run()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.1755

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
ccs 7
cts 9
cp 0.7778
rs 9.2
cc 4
eloc 6
nc 4
nop 1
crap 4.1755
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 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