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

AbstractModifier::create()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 13
cp 0
rs 9.2
c 0
b 0
f 0
nc 8
cc 4
eloc 9
nop 1
crap 20
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