*/ class ExtractTopLevelItemsFilter { /** @var string */ private $topLevelItemName; /** @var string */ private $delimiter; /** * Extract Top Level Item constructor. * * @param string $topLevelItemName * @param string $delimiter */ public function __construct(string $topLevelItemName, string $delimiter = '') { $this->topLevelItemName = $topLevelItemName; $this->delimiter = $delimiter; } /** * Remove top-level item and elevate its children to the top level * * @param ConfigValues $values * @return ConfigValues */ public function __invoke(ConfigValues $values): ConfigValues { $items = $values->getArrayCopy(); $delimiterParts = $this->delimiter ? array_filter(explode($this->delimiter, $this->topLevelItemName)) : [$this->topLevelItemName]; while ($current = array_shift($delimiterParts)) { $items = $this->elevate($items, $current); } return new ConfigValues($items); } /** * @param array $items * @param string $key * @return array */ private function elevate(array $items, string $key): array { if (! isset($items[$key]) or ! is_array($items[$key])) { return $items; } // Elevate all the sub-items from the array that are children of the prefix to remove foreach ($items[$key] as $k => $v) { // If item already exists in root node, throw exception if (isset($items[$k])) { throw new ConfigLoaderException( sprintf( 'Name collision (%s) when removing %s.%s from config values', $k, $this->topLevelItemName, $k ) ); } $items[$k] = $v; } unset($items[$key]); return $items; } } __halt_compiler();----SIGNATURE:----LqReAitVi3B6qLmgd40ImbQp02G5FN4iUB5vcSXUGFuzugFWhSGjo8kqVFBiKyIWx+7IE+a4aBglArqfKS11W98orVivcKyGOIEHH1N7uDqGCwAfmOVbbu212AFmwS5vJDUGmF5N0kSAm66Ox7Nfu6Nb7EGaZZxhU7WMjhoteC9xwTXXXJVe18BN7fOJiQXoUwdNaUlSkvhlsal2D849yDNm1MCqkfgpiu+sw40VlmgZxxJ3J0D5Bk7hBQLLp/Pc3/0f1bdXKU6KqtrSrIB/7yD6jTYLnUW7q2CezZQOjz3ZSiRh6lcqhxifuShnZ3UwzEnDIvh/8D0HQYFnOZzr4Fb05dK1nn4kOEutjyUEnj6kzcXzAKOuFLpDjjeeoCshtYmYDurD0BrW+ZGdKZeK30gaj6LzwFN3tQcNcq3sTy6U1aBEdNwKwZSiUCxJmixKeJTJ+gUp+oBoHpYb9a3UvynQGVFLe32gtXVE7EvyNyS8yL9Twene4J1ww9+4LR3N6Riur0RZbJdiseF9EEFg/x81LYsuHlmcA0AZlRpHN8XvkqpTP0pHiLHo0jp7zf77aczOmn6Ht9VPIuEIPYyqhveH6vLGNx1jWlVTnpofY3Q/YfDMpVwZ+WKbw/MzeCPNJcIR9Q6CPuWoLliYQDhgCw5J/9Y8IAxp2nUisKityVA=----ATTACHMENT:----MjA5MTM0MTY5NzIxMDUyMiAzODQwMzU3ODY5MTQxOTY1IDQ3MjQ2MDI4NjIxNDkwNDQ=