| 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 |
|