Passed
Pull Request — master (#1181)
by Tarmo
06:39 queued 03:09
created

LanguageController::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 7
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Controller/Localization/LanguageController.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Controller\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 LanguageController
19
 *
20
 * @OA\Tag(name="Localization")
21
 *
22
 * @package App\Controller\Localization
23
 * @author TLe, Tarmo Leppänen <[email protected]>
24
 */
25
class LanguageController
26
{
27 2
    public function __construct(
28
        private Localization $localization,
29
    ) {
30 2
    }
31
32
    /**
33
     * Endpoint action to get supported languages. This is for use to choose
34
     * what language your frontend application can use within its translations.
35
     *
36
     * @OA\Response(
37
     *      response=200,
38
     *      description="List of language strings.",
39
     *      @OA\Schema(
40
     *          type="array",
41
     *          example={"en","fi"},
42
     *          @OA\Items(type="string"),
43
     *      ),
44
     *  )
45
     */
46 2
    #[Route(
47
        path: '/localization/language',
48
        methods: [Request::METHOD_GET],
49
    )]
50
    public function __invoke(): JsonResponse
51
    {
52 2
        return new JsonResponse($this->localization->getLanguages());
53
    }
54
}
55