Completed
Push — master ( 0cffd3...28f6d0 )
by Andrii
02:21
created

CompositeModifier   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 36
ccs 9
cts 13
cp 0.6923
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addModifiers() 0 6 1
A run() 0 13 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\lib\modifiers;
12
13
use hiqdev\chkipper\lib\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