Passed
Push — master ( a1fc90...f8dfb5 )
by Tarmo
09:37
created

VersionController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Controller/VersionController.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Controller;
10
11
use App\Service\Version;
12
use Swagger\Annotations as SWG;
13
use Symfony\Component\HttpFoundation\JsonResponse;
14
use Symfony\Component\Routing\Annotation\Route;
15
16
/**
17
 * Class VersionController
18
 *
19
 * @package App\Controller
20
 * @author TLe, Tarmo Leppänen <[email protected]>
21
 */
22
class VersionController
23
{
24
    private Version $version;
25
26
    /**
27
     * VersionController constructor.
28
     */
29 3
    public function __construct(Version $version)
30
    {
31 3
        $this->version = $version;
32 3
    }
33
34
    /**
35
     * Route for get API version.
36
     *
37
     * @Route(
38
     *     path="/version",
39
     *     methods={"GET"}
40
     *  )
41
     *
42
     * @SWG\Response(
43
     *      response=200,
44
     *      description="success",
45
     *      @SWG\Schema(
46
     *          type="object",
47
     *          example={"version": "1.2.3"},
48
     *          @SWG\Property(property="version", type="string", description="Version number"),
49
     *      ),
50
     *  )
51
     */
52 3
    public function __invoke(): JsonResponse
53
    {
54 3
        return new JsonResponse(['version' => $this->version->get()]);
55
    }
56
}
57