Skip to content

Commit

Permalink
CHG: Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
gravataLonga committed May 11, 2020
1 parent dcdb12b commit ffdfbaf
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Expand Up @@ -116,7 +116,7 @@ if (isset($container[FooBar::class])) {

### Alias

Alias like the name indicate, it to make a possibility to make an alias from one entry to another. It will throw exception
Alias like the name indicate, it to make a possibility to make an alias from one entry to another. It will throw an exception.

```php
use Gravatalonga\Container\Container;
Expand All @@ -131,7 +131,23 @@ $container->alias(FooBar::class, 'foo.bar');
$foobar = $container->get('foo.bar');
```

### Callable as alternative

```php
use Gravatalonga\Container\Container;

$class = new class {
public function get(): int
{
return mt_rand(0, 100);
}
};

$container = new Container();
$container->factory('random', [$class, 'get']);

$foobar = $container->get('random'); // it will get random int
```

### Advance usage

Expand Down

0 comments on commit ffdfbaf

Please sign in to comment.