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

CompositeModifier::run()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4.016

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 13
ccs 9
cts 10
cp 0.9
rs 9.2
cc 4
eloc 7
nc 4
nop 1
crap 4.016
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
 * CompositeModifier class.
17
 * Runs multiple modifiers.
18
 *
19
 * @author Andrii Vasyliev <[email protected]>
20
 */
21
class CompositeModifier extends AbstractModifier
22
{
23
    /**
24
     * @var array list of modifiers to run
25
     */
26
    public $modifiers = [];
27
28
    /**
29
     * Add modifiers.
30
     * @param array $modifiers
31
     * @return self for chaining
32
     */
33
    public function addModifiers(array $modifiers)
34
    {
35
        $this->modifiers = array_merge($this->modifiers, $modifiers);
36
37
        return $this;
38
    }
39
40
    /**
41
     * Removes first tag if it is empty: has no notes and no commits.
42
     */
43 2
    public function run(History $history)
44
    {
45 2
        foreach ($this->modifiers as $name => $config) {
46 2
            if (is_null($config)) {
47
                continue;
48
            }
49
50 2
            if (empty($config['class'])) {
51 2
                $config['class'] = $name;
52 2
            }
53 2
            static::create($config)->run($history);
54 2
        }
55 2
    }
56
}
57