ArrayUtil.php
3 years ago
Config.php
3 years ago
ConfigCollection.php
3 years ago
ConfigCollectionFactory.php
3 years ago
ConfigCollectionInterface.php
3 years ago
ConfigFactory.php
3 years ago
ConfigInterface.php
3 years ago
Filesystem.php
3 years ago
FilesystemInterface.php
3 years ago
Imposter.php
3 years ago
ImposterFactory.php
3 years ago
ImposterInterface.php
3 years ago
ProjectConfig.php
3 years ago
ProjectConfigInterface.php
3 years ago
StringUtil.php
3 years ago
Transformer.php
3 years ago
TransformerInterface.php
3 years ago
ConfigCollection.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace TypistTech\Imposter; |
| 6 | |
| 7 | class ConfigCollection implements ConfigCollectionInterface |
| 8 | { |
| 9 | /** |
| 10 | * @var ConfigInterface[] |
| 11 | */ |
| 12 | private $configs = []; |
| 13 | |
| 14 | /** |
| 15 | * @param ConfigInterface $config |
| 16 | * |
| 17 | * @return void |
| 18 | */ |
| 19 | public function add(ConfigInterface $config) |
| 20 | { |
| 21 | $this->configs[$config->getPackageDir()] = $config; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * @return string[] |
| 26 | */ |
| 27 | public function getAutoloads(): array |
| 28 | { |
| 29 | $autoloads = ArrayUtil::flattenMap(function (ConfigInterface $config) { |
| 30 | return $config->getAutoloads(); |
| 31 | }, $this->all()); |
| 32 | |
| 33 | return array_unique($autoloads); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @return ConfigInterface[] |
| 38 | */ |
| 39 | public function all(): array |
| 40 | { |
| 41 | return $this->configs; |
| 42 | } |
| 43 | } |
| 44 |