Skip to content

Commit

Permalink
Updated Container class so that you can set variables more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Jan 24, 2022
1 parent e18931c commit 812aca9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion system/classes/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ public function get($id)
* @param string $id
* @param mixed $item
* @return void
* @note You can set variables more than once, but can only set objects once.
*/
public function set($id, $item)
{
if ($this->has($id)) {
if ($this->has($id) && is_object($this->data[$id])) {
throw new InvalidArgumentException(__METHOD__ . ": item named '$id' already exists");
} else {
$this->data[$id] = $item;
Expand Down

0 comments on commit 812aca9

Please sign in to comment.