Skip to content

Commit

Permalink
simplify Space::flattenSections()
Browse files Browse the repository at this point in the history
  • Loading branch information
wyrfel committed Jun 8, 2017
1 parent 5e3345f commit 9f93bc2
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/Space.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,14 @@ protected function flattenSections(array $config): array
{
$merged = [];

$sections = $this->getSections();
$sections = array_unique($this->getSections());

if (empty($sections)) {
throw new PreconditionException('No sections have been configured.');
}

foreach (array_unique($this->getSections()) as $section) {
$section = strtolower($section);

if (!isset($config[$section])) {
continue;
}

$merged = $this->merge($merged, $config[$section]);
foreach ($sections as $section) {
$merged = $this->merge($merged, $config[strtolower($section)] ?? []);
}

return $merged;
Expand Down

0 comments on commit 9f93bc2

Please sign in to comment.