Test Failed
Push — master ( cafe13...7a2929 )
by Enrico
02:56
created

MyRequestProcessor::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
require_once __DIR__.'/../vendor/autoload.php';
3
4
use uSilex\Application;
5
use uSilex\Provider\Psr15\RelayServiceProvider;
6
use uSilex\Provider\Psr7\DiactorosServiceProvider;
7
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
use Psr\Http\Server\MiddlewareInterface;
12
use Zend\Diactoros\Response\TextResponse;
13
14
class MyRequestProcessor implements MiddlewareInterface {
15
    use \uSilex\Psr11Trait;
16
    
17
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
18
    {
19
        return new TextResponse( $this->get('message'));
20
    }
21
}  
22
23
$app = new Application;
24
$app->register( new RelayServiceProvider());
25
$app->register( new DiactorosServiceProvider());
26
$app['message'] = 'hello world!';
27
$app['myMiddleware'] = function($app){
28
    return new MyRequestProcessor($app) ;
29
};
30
$app['handler.queue'] = ['myMiddleware'];
31
32
$app->run();
33