Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 120896c

Browse files
committed
Bring back construtor implementation to simplify code
1 parent ce9d4c5 commit 120896c

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/Config.php

+4-18
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ class Config implements ConfigInterface
5050
public function __construct(array $config = [])
5151
{
5252
// Only merge keys we're interested in
53-
foreach (array_keys($this->allowedKeys) as $requiredKey) {
54-
if ($this->isValidValue($config, $requiredKey)) {
55-
if ($this->isValidValue($this->config, $requiredKey)) {
56-
$this->config[$requiredKey] = $this->merge($this->config[$requiredKey], $config[$requiredKey]);
57-
} else {
58-
$this->config[$requiredKey] = $config[$requiredKey];
59-
}
53+
foreach (array_keys($config) as $key) {
54+
if (! isset($this->allowedKeys[$key])) {
55+
unset($config[$key]);
6056
}
6157
}
58+
$this->config = $this->merge($this->config, $config);
6259
}
6360

6461
/**
@@ -77,17 +74,6 @@ public function toArray()
7774
return $this->config;
7875
}
7976

80-
/**
81-
* @param array $array
82-
* @param string $key
83-
*
84-
* @return bool
85-
*/
86-
private function isValidValue(array $array, $key)
87-
{
88-
return isset($array[$key]) && is_array($array[$key]);
89-
}
90-
9177
/**
9278
* Copy paste from https://github.com/zendframework/zend-stdlib/commit/26fcc32a358aa08de35625736095cb2fdaced090
9379
* to keep compatibility with previous version

0 commit comments

Comments
 (0)