<commit_before>#Middleware (v0.0.*)
This package lets u manage middleware for a HTTP request and response that implement the [PSR-7](https://github.com/php-fig/fig-standards/blob/master/proposed/http-message.md) HTTP message interfaces
`Psr\Http\Message\ServerRequestInterface` and `Psr\Http\Message\ResponseInterface`.

[![Build Status](https://api.travis-ci.org/websoftwares/middleware.png)](https://travis-ci.org/websoftwares/middleware)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/websoftwares/middleware/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/websoftwares/middleware/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/websoftwares/middleware/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/websoftwares/middleware/?branch=master)

## Installing via Composer (recommended)

Install composer in your project:
```
curl -s http://getcomposer.org/installer | php
```

Create a composer.json file in your project root:
```php
{
    "require": {
		"websoftwares/middleware": ~0.0.1"
    }
}
```

Install via composer
```
php composer.phar install
```

## Usage
Basic usage of the `Middleware` class.

```php
use Websoftwares\Middleware;

$middleware = new Middleware;

// Some middleware object that is callable through invoke or a closure 
// for consistency u could implement the `Websoftwares\HandlerInterface`.

// Invokable object
$throttleMiddleware = new ThrotteObject

// request + middelewareOne decoration <= objects are passed by reference
$middelewareOne = function($request, $response) {
    // Decorate the foo property
    $request->foo = $request->foo + 1;
};

// response + middlewareTwo decoration <= objects are passed by reference
$middlewareTwo = function($request, $response) {
    // / Decorate the bar property
    $response->bar = $response->bar . ' World';
};

$middleware->addHandler($throttleMiddleware);
$middleware->addHandler($middelewareOne);
$middleware->addHandler($middlewareTwo);
...
// Add more middleware
...

$middleware = $this->middleware;

// Call
$middleware($request, $response);

```

## Changelog
- v0.0.3: Decorate the request and response example and tests added.
- v0.0.2: Small fixes
- v0.0.1: Initial 

## Testing
In the tests folder u can find several tests.

## Acknowledgement
Inspired by all the great middleware packages

- [Interpose](https://github.com/carbocation/interpose)
- [StackPHP](http://stackphp.com)
- [Conduit](https://github.com/bigeasy/conduit)
- [Conduit-php](https://github.com/phly/conduit)
- [Rack](https://github.com/rack/rack)

## License
The [MIT](http://opensource.org/licenses/MIT "MIT") License (MIT).
<commit_msg>Edit readme<commit_after>#Middleware (v0.0.*)
This package lets u manage middleware for a HTTP request and response that implement the [PSR-7](https://github.com/php-fig/fig-standards/blob/master/proposed/http-message.md) HTTP message interfaces
`Psr\Http\Message\ServerRequestInterface` and `Psr\Http\Message\ResponseInterface`.

[![Build Status](https://api.travis-ci.org/websoftwares/middleware.png)](https://travis-ci.org/websoftwares/middleware)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/websoftwares/middleware/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/websoftwares/middleware/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/websoftwares/middleware/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/websoftwares/middleware/?branch=master)

## Installing via Composer (recommended)

Install composer in your project:
```
curl -s http://getcomposer.org/installer | php
```

Create a composer.json file in your project root:
```php
{
    "require": {
		"websoftwares/middleware": ~0.0.1"
    }
}
```

Install via composer
```
php composer.phar install
```

## Usage
Basic usage of the `Middleware` class.

```php
use Websoftwares\Middleware;

$middleware = new Middleware;

// Some middleware object that is callable through invoke or a closure 
// for consistency u could implement the `Websoftwares\HandlerInterface`.

// Invokable object
$throttleMiddleware = new ThrotteObject

// request + middelewareOne decoration <= objects are passed by reference
$middelewareOne = function($request, $response) {
    // Decorate the foo property
    $request->foo = $request->foo + 1;
};

// response + middlewareTwo decoration <= objects are passed by reference
$middlewareTwo = function($request, $response) {
    // / Decorate the bar property
    $response->bar = $response->bar . ' World';
};

$middleware->addHandler($throttleMiddleware);
$middleware->addHandler($middelewareOne);
$middleware->addHandler($middlewareTwo);
...
// Add more middleware
...

// Call
$middleware($request, $response);

```

## Changelog
- v0.0.3: Decorate the request and response example and tests added.
- v0.0.2: Small fixes
- v0.0.1: Initial 

## Testing
In the tests folder u can find several tests.

## Acknowledgement
Inspired by all the great middleware packages

- [Interpose](https://github.com/carbocation/interpose)
- [StackPHP](http://stackphp.com)
- [Conduit](https://github.com/bigeasy/conduit)
- [Conduit-php](https://github.com/phly/conduit)
- [Rack](https://github.com/rack/rack)

## License
The [MIT](http://opensource.org/licenses/MIT "MIT") License (MIT).

{'fraction_non_alphanumeric': 0.1492989768851838, 'fraction_numerical': 0.0060629026146267525, 'mean_word_length': 4.731813246471227, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 18, 'https://': 22, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5658734', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1718, 'n_words': 379}