Test Failed
Push — develop ( 833877...64b6b0 )
by nguereza
02:36
created

MyRequestHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace Platine\Framework;
10
11
use Platine\Framework\Http\RequestData;
12
use Platine\Http\Handler\RequestHandlerInterface;
13
use Platine\Http\Response;
14
use Platine\Http\ResponseInterface;
15
use Platine\Http\ServerRequestInterface;
16
use Platine\Logger\LoggerInterface;
17
18
/**
19
 * Description of MyRequestHandler
20
 *
21
 * @author tony
22
 */
23
class MyRequestHandler implements RequestHandlerInterface
24
{
25
26
    protected LoggerInterface $logger;
27
28
    /**
29
     * Create new instance
30
     * @param LoggerInterface $logger
31
     */
32
    public function __construct(LoggerInterface $logger)
33
    {
34
        $this->logger = $logger;
35
    }
36
37
    public function handle(ServerRequestInterface $request): ResponseInterface
38
    {
39
        //$param = new RequestData($request);
40
41
        $name = $request->getAttribute('name', 'Tony');
42
        $this->logger->info('User name is {name}', ['name' => $name]);
43
        $resp = new Response(200);
44
        $resp->getBody()->write("Hello ${name}");
45
46
        return $resp->withHeader('Framework', 'Platine PHP');
47
    }
48
}
49