Completed
Push — master ( fdef12...11a376 )
by Andrii
02:13
created

AbstractModifier   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 20
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
run() 0 1 ?
A create() 0 15 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
 * Abstract modifier class.
17
 *
18
 * @author Andrii Vasyliev <[email protected]>
19
 */
20
abstract class AbstractModifier implements ModifierInterface
21
{
22
    abstract public function run(History $history);
23
24
    public static function create(array $config)
25
    {
26
        $class = isset($config['class']) ? $config['class'] : $name;
0 ignored issues
show
Bug introduced by
The variable $name does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
27
        unset($config['class']);
28
29
        if (!class_exists($class)) {
30
            $class = __NAMESPACE__ . '\\' . $class;
31
        }
32
        $modifier = new $class();
33
        foreach ($config as $key => $value) {
34
            $modifier->$key = $value;
35
        }
36
37
        return $modifier;
38
    }
39
}
40