Skip to content

Commit

Permalink
add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Mar 4, 2022
1 parent 0969dfb commit f9ec8ae
Showing 1 changed file with 3 additions and 31 deletions.
34 changes: 3 additions & 31 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

class Config implements ArrayAccess, \JsonSerializable
{
/**
* @var array
*/
protected array $config;

/**
Expand All @@ -20,20 +17,10 @@ public function __construct(array $config)
$this->config = $config;
}

/**
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get(string $key, $default = null)
public function get(string $key, mixed $default = null): mixed
{
$config = $this->config;

if (is_null($key)) {
return $config;
}

if (isset($config[$key])) {
return $config[$key];
}
Expand All @@ -48,18 +35,8 @@ public function get(string $key, $default = null)
return $config;
}

/**
* @param string $key
* @param mixed $value
*
* @return array
*/
public function set(string $key, $value)
public function set(string $key, $value): mixed
{
if (is_null($key)) {
throw new InvalidArgumentException('Invalid config key.');
}

$keys = explode('.', $key);
$config = &$this->config;

Expand All @@ -76,11 +53,6 @@ public function set(string $key, $value)
return $config;
}

/**
* @param string $key
*
* @return bool
*/
public function has(string $key): bool
{
return (bool) $this->get($key);
Expand All @@ -106,7 +78,7 @@ public function offsetUnset(mixed $offset): void
$this->set($offset, null);
}

public function jsonSerialize(): mixed
public function jsonSerialize(): array
{
return $this->config;
}
Expand Down

0 comments on commit f9ec8ae

Please sign in to comment.