<commit_before>## Container [![Build Status](https://travis-ci.org/php-packages/container.svg?branch=master)](https://travis-ci.org/php-packages/container)

An IoC container for PHP: simple, fast, clean.

### Features

- Injecting via type-hinting.
- Injecting via annotations.
- Manual dependencies injecting (via an array).

## Navigation

- [Installation](#installation)
- [Usage](#usage)
- [Testing](#testing)
- [Additional information](#additional-information)

## Installation

```shell
composer require php-packages/container
```

## Usage

```php
$container = new \PhpPackages\Container\Container;
```

### mixed make(string|mixed $class, array $dependencies = [])

```php
class A
{
}

get_class($container->make("A")); # => "A"
get_class($container->make(new A)); # => "A"

class B
{

    public function __construct(array $foo = [], A $bar)
    {
        get_class($bar); # => "A"
    }
}

$container->make("B");

class C
{

    public function __construct(array $foo)
    {
        var_dump($foo); # => [1, 2, 3]
    }
}

$container->make("C", [[1, 2, 3]]);
```

### object inject(object $instance)

The `inject` method be always called inside of `make`.

```php
class C
{
}

class A
{

    /**
     * @shouldBeInjected
     * @var C
     */
    public $b;
}

get_class($container->inject(new A)->b); # => "C"
```

## Testing

```shell
git clone https://github.com/php-packages/container.git; cd container
composer install --dev # or "composer update"
make run-specs boot-server # visit http://localhost:8000
```

## Additional information

*Container* is released under the MIT license.<commit_msg>Update the readme, fix invalid Make targets.<commit_after>## Container [![Build Status](https://travis-ci.org/php-packages/container.svg?branch=master)](https://travis-ci.org/php-packages/container)

An IoC container for PHP: simple, fast, clean.

### Features

- injecting via type-hinting
- injecting via property annotations
- manual dependencies injecting via an array

## Navigation

- [Installation](#installation)
- [Usage](#usage)
- [Development](#development)
- [Additional information](#additional-information)

## Installation

```shell
composer require php-packages/container
```

## Usage

### mixed make(string|mixed $class, array $dependencies = [])

```php
class A
{
}

get_class($container->make("A")); # => "A"
get_class($container->make(new A)); # => "A"

class B
{

    public function __construct(array $foo = [], A $bar)
    {
        var_dump($foo); # => []
        get_class($bar); # => "A"
    }
}

$container->make("B");

class C
{

    public function __construct(array $foo)
    {
        var_dump($foo); # => [1, 2, "C"]
    }
}

$container->make("C", [[1, 2, raw("C")]]);
```

### object inject(object $instance)

The `inject` method be always called inside of `make`.

```php
class C
{
}

class A
{

    /**
     * @shouldBeInjected
     * @var C
     */
    public $b;
}

get_class($container->inject(new A)->b); # => "C"
```

## Development

```shell
make run-tests
make coverage-report coverage-report-server
```

## Additional information

*Container* is released under the MIT license.
{'fraction_non_alphanumeric': 0.18045352922389013, 'fraction_numerical': 0.004471414883423826, 'mean_word_length': 3.8184615384615386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7330496', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1016, 'n_words': 254}