diff --git a/src/Config.php b/src/Config.php index 7cb889e..a52b915 100644 --- a/src/Config.php +++ b/src/Config.php @@ -57,6 +57,14 @@ public function set($key, $value) * {@inheritdoc} */ public function import($data) + { + return $this->replace($data); + } + + /** + * {@inheritdoc} + */ + public function replace($data) { $this->config = new Data($data); return $this; diff --git a/src/ConfigInterface.php b/src/ConfigInterface.php index 35b85b4..5124ea1 100644 --- a/src/ConfigInterface.php +++ b/src/ConfigInterface.php @@ -35,14 +35,30 @@ public function set($key, $value); * Import configuration from the provided nexted array, replacing whatever * was here previously. No processing is done on the provided data. * + * @deprecated Use 'replace'. Dflydev\DotAccessData\Data::import() merges, which is confusing, since this method replaces. + * * @param array $data * @return Config */ public function import($data); + /** + * Load configuration from the provided nexted array, replacing whatever + * was here previously. No processing is done on the provided data. + * + * TODO: This will become a required method in version 2.0. Adding now + * would break clients that implement ConfigInterface. + * + * @param array $data + * @return Config + */ + // public function replace($data); + /** * Import configuration from the provided nexted array, merging with whatever * was here previously. No processing is done on the provided data. + * Any data provided to the combine() method will overwrite existing data + * with the same key. * * TODO: This will become a required method in version 2.0. Adding now * would break clients that implement ConfigInterface. diff --git a/src/Util/ConfigOverlay.php b/src/Util/ConfigOverlay.php index 24b345a..d1f1269 100644 --- a/src/Util/ConfigOverlay.php +++ b/src/Util/ConfigOverlay.php @@ -137,7 +137,15 @@ public function set($key, $value) */ public function import($data) { - throw new \Exception('The method "import" is not supported for the ConfigOverlay class.'); + $this->unsupported(__FUNCTION__); + } + + /** + * @inheritdoc + */ + public function replace($data) + { + $this->unsupported(__FUNCTION__); } /** @@ -145,7 +153,15 @@ public function import($data) */ public function combine($data) { - throw new \Exception('The method "combine" is not supported for the ConfigOverlay class.'); + $this->unsupported(__FUNCTION__); + } + + /** + * @inheritdoc + */ + protected function unsupported($fn) + { + throw new \Exception("The method '$fn' is not supported for the ConfigOverlay class."); } /**