Passed
Push — master ( 14a42b...4e4f6b )
by Andrii
02:16
created

ConfigFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 13
dl 0
loc 24
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 2
1
<?php
2
/**
3
 * Composer plugin for config assembling
4
 *
5
 * @link      https://github.com/hiqdev/composer-config-plugin
6
 * @package   composer-config-plugin
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\composer\config\configs;
12
13
use hiqdev\composer\config\Builder;
14
15
/**
16
 * Config factory creates Config object of proper class
17
 * according to config name (and mayby other options later).
18
 *
19
 * @author Andrii Vasyliev <[email protected]>
20
 */
21
class ConfigFactory
22
{
23
    private static $loaders;
0 ignored issues
show
introduced by
The private property $loaders is not used, and could be removed.
Loading history...
24
25
    private static $knownTypes = [
26
        '__rebuild'     => Rebuild::class,
27
        '__files'       => System::class,
28
        'aliases'       => System::class,
29
        'extensions'    => System::class,
30
        'params'        => Params::class,
31
        'defines'       => Defines::class,
32
    ];
33
34
    /**
35
     * @return Config
36
     */
37 1
    public static function create(Builder $builder, string $name)
38
    {
39 1
        $class = isset(static::$knownTypes[$name])
0 ignored issues
show
Bug introduced by
Since $knownTypes is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $knownTypes to at least protected.
Loading history...
40 1
            ? static::$knownTypes[$name]
41 1
            : Config::class
42
        ;
43 1
44
        return new $class($builder, $name);
45
    }
46
}
47