ConfigFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 23
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 6 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
 * @since php5.5
22
 */
23
class ConfigFactory
24
{
25
    private static $knownTypes = [
26
        '__rebuild'     => Rebuild::class,
27
        '__files'       => System::class,
28
        'aliases'       => System::class,
29
        'packages'      => System::class,
30
        'dotenv'        => DotEnv::class,
31
        'params'        => Params::class,
32
        'defines'       => Defines::class,
33
    ];
34
35
    /**
36
     * @param Builder $builder
37
     * @param string $name
38
     * @return Config
39
     */
40 1
    public static function create(Builder $builder, $name)
41
    {
42
//        $class = static::$knownTypes[$name] ?? Config::class;
43 1
        $class = isset(static::$knownTypes[$name]) ? static::$knownTypes[$name] : Config::class;
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...
44
45 1
        return new $class($builder, $name);
46
    }
47
}
48