Skip to content

Commit

Permalink
Ensure aliases return the correct stored object
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewhiteley committed Nov 10, 2018
1 parent 5a868a5 commit 9c8e314
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ObjectStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public function instance(string $key, $object)
*/
public function store(string $key, $object)
{
if (isset($this->aliases[$key])) {
$key = $this->aliases[$key];
}

$this->store[$key] = $object;
}

Expand Down Expand Up @@ -193,7 +197,7 @@ public function getStored(string $key)
* @since 1.0.0
*
* @param string $key Object key.
* @return object
* @return callable
*/
public function getFactory(string $key)
{
Expand Down Expand Up @@ -295,8 +299,8 @@ protected function removeAliasFor($key)
*
* @since 1.0.0
*
* @throws Hodl\Exceptions\InvalidKeyException if the key if not a valid class name.
* @throws Hodl\Exceptions\KeyExistsException if the key already exists.
* @throws \Hodl\Exceptions\InvalidKeyException If the key if not a valid class name.
* @throws \Hodl\Exceptions\KeyExistsException If the key already exists.
*
* @param string $key The key to check.
*/
Expand Down

0 comments on commit 9c8e314

Please sign in to comment.