Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammetsafak committed Dec 23, 2023
1 parent c23ae13 commit 9cc333b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public function set(string $id, $concrete = null)
$concrete = $id;
}

if (is_string($concrete) && class_exists($concrete)) {
$concrete = $this->resolve($concrete);
}

return $this->instance[$id] = $concrete;
}

Expand All @@ -40,16 +44,8 @@ public function get(string $id)
if(!$this->has($id)){
$this->set($id);
}
$instance = $this->instance[$id];
if (is_object($instance)) {
return $instance;
}

if (is_string($instance) && class_exists($instance)) {
return $this->set($id, $this->resolve($instance));
}

return $instance;
return $this->instance[$id];
}

/**
Expand Down

0 comments on commit 9cc333b

Please sign in to comment.