Skip to content

Commit

Permalink
Update Container.php
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 authored Aug 4, 2024
1 parent 5a7d9a0 commit 6d391c7
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class Container

public static function getInstance()
{
if (!isset(static::$instances)) {
if (!isset(static::$instances))
static::$instances = new self();
}

return static::$instances;
}
Expand All @@ -32,18 +31,16 @@ public function bind(string $key, mixed $value): mixed

public function singleton(string $key, object $value)
{
if (!$this->has($key)) {
if (!$this->has($key))
return $this->bind($key, $value);
}

return $this->storage[$key];
}

public function key(string $key)
{
if ($this->has($key)) {
if ($this->has($key))
return $key;
}

throw new \Exception("Key '{$key}' not found in container.");
}
Expand Down

0 comments on commit 6d391c7

Please sign in to comment.