LanguageController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 19 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Controller/v1/Localization/LanguageController.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Controller\v1\Localization;
10
11
use App\Service\Localization;
0 ignored issues
show
Bug introduced by
The type App\Service\Localization was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use OpenApi\Attributes as OA;
13
use OpenApi\Attributes\JsonContent;
14
use Symfony\Component\HttpFoundation\JsonResponse;
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\HttpKernel\Attribute\AsController;
17
use Symfony\Component\Routing\Annotation\Route;
18
19
/**
20
 * Class LanguageController
21
 *
22
 * @package App\Controller\v1\Localization
23
 * @author TLe, Tarmo Leppänen <[email protected]>
24
 */
25
#[AsController]
26
#[OA\Tag(name: 'Localization')]
27
class LanguageController
28
{
29 3
    public function __construct(
30
        private readonly Localization $localization,
31
    ) {
32 3
    }
33
34
    /**
35
     * Endpoint action to get supported languages. This is for use to choose
36
     * what language your frontend application can use within its translations.
37
     */
38 3
    #[Route(
39
        path: '/v1/localization/language',
40
        methods: [Request::METHOD_GET],
41
    )]
42
    #[OA\Response(
43
        response: 200,
44
        description: 'List of language strings.',
45
        content: new JsonContent(
46
            type: 'array',
47
            items: new OA\Items(
48
                type: 'string',
49
                example: 'en',
50
            ),
51
            example: ['en', 'fi'],
52
        ),
53
    )]
54
    public function __invoke(): JsonResponse
55
    {
56 3
        return new JsonResponse($this->localization->getLanguages());
57
    }
58
}
59