Completed
Push — master ( b0e9fb...0c2496 )
by Tarmo
35s queued 13s
created

LocaleController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 1
A __construct() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Controller/v1/Localization/LocaleController.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Controller\v1\Localization;
10
11
use App\Service\Localization;
12
use OpenApi\Annotations as OA;
13
use Symfony\Component\HttpFoundation\JsonResponse;
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\Routing\Annotation\Route;
16
17
/**
18
 * Class LocaleController
19
 *
20
 * @OA\Tag(name="Localization")
21
 *
22
 * @package App\Controller\v1\Localization
23
 * @author TLe, Tarmo Leppänen <[email protected]>
24
 */
25
class LocaleController
26
{
27 2
    public function __construct(
28
        private Localization $localization,
29
    ) {
30 2
    }
31
32
    /**
33
     * Endpoint action to get supported locales. This is for use to choose what
34
     * locale your frontend application can use within its number, time, date,
35
     * datetime, etc. formatting.
36
     *
37
     * @OA\Response(
38
     *      response=200,
39
     *      description="List of locale strings.",
40
     *      @OA\Schema(
41
     *          type="array",
42
     *          example={"en","fi"},
43
     *          @OA\Items(type="string"),
44
     *      ),
45
     *  )
46
     */
47 2
    #[Route(
48
        path: '/v1/localization/locale',
49
        methods: [Request::METHOD_GET],
50
    )]
51
    public function __invoke(): JsonResponse
52
    {
53 2
        return new JsonResponse($this->localization->getLocales());
54
    }
55
}
56