Completed
Push — master ( ff98ab...5f77cb )
by Dawid
19s
created

Application::sayHello()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 4
c 1
b 0
f 0
cc 1
nc 1
nop 1
rs 10
1
<?php declare(strict_types=1);
2
3
use FatCode\OpenApi\Annotation as Api;
4
use FatCode\OpenApi\Http\Response;
5
use FatCode\OpenApi\Schema\TextPlain;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
9
/**
10
 * @Api\Application(
11
 *     version="1.0.0",
12
 *     title="Example get route",
13
 *     servers=[
14
 *         @Api\Server(port=8080, host="localhost")
15
 *     ],
16
 * )
17
 */
18
class Application
19
{
20
    /**
21
     * @Api\PathItem\Get(
22
     *     route="/hello/{name<\w>}",
23
     *     responses=[
24
     *         @Api\Response(code=200, schema=@Api\Reference(TextPlain::class))
25
     *     ]
26
     * )
27
     *
28
     * @param ServerRequestInterface $request
29
     * @return ResponseInterface
30
     */
31
    public function sayHello(ServerRequestInterface $request) : ResponseInterface
32
    {
33
        // Return text/plain response
34
        return new Response(200, "Hello: {$request->getAttribute('name')}");
35
    }
36
}
37