| 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 $knownTypes = [ |
||
| 24 | '__rebuild' => Rebuild::class, |
||
| 25 | '__files' => System::class, |
||
| 26 | 'aliases' => System::class, |
||
| 27 | 'packages' => System::class, |
||
| 28 | 'dotenv' => DotEnv::class, |
||
| 29 | 'params' => Params::class, |
||
| 30 | 'defines' => Defines::class, |
||
| 31 | ]; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param Builder $builder |
||
| 35 | * @param string $name |
||
| 36 | * @return Config |
||
| 37 | 1 | */ |
|
| 38 | public static function create(Builder $builder, string $name): Config |
||
| 39 | 1 | { |
|
| 40 | 1 | $class = static::$knownTypes[$name] ?? Config::class; |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 41 | 1 | ||
| 42 | return new $class($builder, $name); |
||
| 43 | 1 | } |
|
| 44 | } |
||
| 45 |