|
1 | 1 | # Moon - Container |
2 | | -A very simple Container |
3 | 2 |
|
4 | | -[](https://codeclimate.com/github/moon-php/container) [](https://travis-ci.org/moon-php/container) |
| 3 | +[](https://scrutinizer-ci.com/g/moon-php/container/?branch=master) |
| 4 | +[](https://scrutinizer-ci.com/g/moon-php/container/?branch=master) |
| 5 | +[](https://scrutinizer-ci.com/g/moon-php/container/build-status/master) |
5 | 6 |
|
6 | | -## Introduction |
| 7 | +###[Documentation](http://moon-php.com/docs/container/) |
7 | 8 |
|
8 | | -Container is a standalone component incredibly easy. |
9 | | -It's a container (yes, really) that implements only the container-interop interface (waiting the PSR-11) without other method. |
| 9 | +## Tests |
10 | 10 |
|
11 | | -## Usage |
12 | | -The container accept as constructor argument, an associative array. |
13 | | -The key (a.k.a alias) always has an entry. |
| 11 | +To execute the test suite, you'll need phpunit. |
| 12 | +_It's a dev-dependency of this package_ |
14 | 13 |
|
15 | | -#### Init Container |
| 14 | +```bash |
| 15 | +$ php vendon/bin/phpunit |
| 16 | +``` |
16 | 17 |
|
17 | | - $entries = [ |
18 | | - 'alias' => function () { |
19 | | - return new App\Acme\Class(); |
20 | | - } |
21 | | - ]; |
22 | | - $container = new Container($entries); |
23 | | - |
24 | | -The entry can be anything: an integer, a string, a closure or an instance. |
| 18 | +## Contributing |
25 | 19 |
|
26 | | -#### Check if entry exists by alias |
| 20 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
27 | 21 |
|
28 | | - $entries = [...]; |
29 | | - $container = new Moon\Container($entries); |
30 | | - $container->has('alias'); // Return true or false |
| 22 | +## Learn More |
31 | 23 |
|
32 | | -#### Getting an entry |
| 24 | +Learn more at these links: |
33 | 25 |
|
34 | | - $entries = [...]; |
35 | | - $c = new Moon\Container($entries); |
36 | | - $container->get('alias'); // Return the instance or throw a Moon\Container\Exception\NotFoundException |
37 | | - |
| 26 | +- [Website](http://moon-php.com) |
38 | 27 |
|
39 | | -#### Entry with container resolution |
| 28 | +## Security |
40 | 29 |
|
41 | | -An entry may require an instance of the container for other entries. |
42 | | -In this case, just use an argument in the function where the container instance will be bound. |
43 | | - |
44 | | - $entries = []; |
45 | | - $entries['ten'] = 10; |
46 | | - $entries['two'] = 2; |
47 | | - $entries['multiply'] = function ($c) { |
48 | | - return $c->get('ten') * $c->get('two'); |
49 | | - }; |
50 | | - $c = new Moon\Container($entries); |
51 | | - $c->get('multiply'); // Return 20 |
| 30 | +If you discover security related issues, please email damianopetrungaro@gmail.com instead of using the issue tracker. |
| 31 | + |
| 32 | +## License |
| 33 | + |
| 34 | +The Moon Container is licensed under the MIT license. See [License File](LICENSE.md) for more information. |
0 commit comments