Skip to content

Commit

Permalink
ADD: isAlias
Browse files Browse the repository at this point in the history
  • Loading branch information
gravataLonga committed May 18, 2020
1 parent 79ce76f commit 898f07d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Container.php
Expand Up @@ -127,6 +127,16 @@ public function has($id)
array_key_exists($id, $this->aliases);
}

/**
* @param string $id
*
* @return bool
*/
public function isAlias($id)
{
return true === array_key_exists($id, $this->aliases);
}

/**
* @param string $id
* @param array<string, mixed> $arguments
Expand Down
11 changes: 11 additions & 0 deletions tests/AliasMethodTest.php
Expand Up @@ -61,6 +61,17 @@ public function testAliasOneVarToAnotherVar()
self::assertSame($container->get('foobar'), $container->get('hello'));
}

public function testCanCheckIfEntryIsAliases()
{
$container = new Container();
$container->factory('myEntry', ['1', '2', '3']);
$container->alias('myEntry', 'myEntryAlias');

self::assertTrue($container->isAlias('myEntryAlias'));
self::assertFalse($container->isAlias('myEntry'));
self::assertFalse($container->isAlias('notExists'));
}

public function testCanUseMakeOverAlias()
{
$container = new Container();
Expand Down

0 comments on commit 898f07d

Please sign in to comment.