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

AbstractModifier::run()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
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