Skip to content

Commit

Permalink
Deprecate Config::import(); recommand Config::replace() instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson committed Oct 17, 2017
1 parent 21bef7b commit 57c9169
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/Config.php
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions src/ConfigInterface.php
Expand Up @@ -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.
Expand Down
20 changes: 18 additions & 2 deletions src/Util/ConfigOverlay.php
Expand Up @@ -137,15 +137,31 @@ 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__);
}

/**
* @inheritdoc
*/
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.");
}

/**
Expand Down

0 comments on commit 57c9169

Please sign in to comment.