JimChenWYU /
composer-config-plugin
| 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
Loading history...
|
|||
| 44 | |||
| 45 | 1 | return new $class($builder, $name); |
|
| 46 | } |
||
| 47 | } |
||
| 48 |