Skip to content

Commit

Permalink
Update src/Config/ConfigFile.php
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Thomson <git@alfreido.com>
  • Loading branch information
jaxwilko and bennothommo authored Jul 6, 2021
1 parent 31c405a commit 581e616
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/Config/ConfigFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,22 @@ public static function read(string $file): ?ConfigFile
}

/**
* @param string $key
* @param $value
* @param string|array $key
* @param string|null $value
* @return $this
*/
public function set(): ConfigFile
public function set($key, string $value = null): ConfigFile
{
$args = func_get_args();

if (count($args) === 1 && is_array($args[0])) {
foreach ($args[0] as $key => $value) {
$this->set($key, $value);
if (is_array($key)) {
foreach ($key as $name => $value) {
$this->set($name, $value);
}

return $this;
}

if (count($args) !== 2 || !is_string($args[0])) {
throw new \InvalidArgumentException('invalid args passed');
if ($key && is_null($value)) {
throw new ApplicationException('You must specify a value to set for the given key.');
}

list($key, $value) = $args;
Expand Down

0 comments on commit 581e616

Please sign in to comment.