ApiInfo   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 5
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A process() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Server\MiddlewareInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
use Yiisoft\DataResponse\DataResponseFactoryInterface;
12
use OpenApi\Annotations as OA;
13
14
/**
15
 * @OA\Info(title="Yii demo API", version="2.0")
16
 */
17
class ApiInfo implements MiddlewareInterface
18
{
19
    private DataResponseFactoryInterface $responseFactory;
20
21
    public function __construct(DataResponseFactoryInterface $responseFactory)
22
    {
23
        $this->responseFactory = $responseFactory;
24
    }
25
26
    /**
27
     * @OA\Get(
28
     *     path="/api/info/v2",
29
     *     @OA\Response(response="200", description="Get api version")
30
     * )
31
     */
32
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
33
    {
34
        return $this->responseFactory->createResponse(['version' => '2.0', 'author' => 'yiisoft']);
35
    }
36
}
37