LocaleController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 33
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/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;
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 LocaleController
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 LocaleController
28
{
29 3
    public function __construct(
30
        private readonly Localization $localization,
31
    ) {
32 3
    }
33
34
    /**
35
     * Endpoint action to get supported locales. This is for use to choose what
36
     * locale your frontend application can use within its number, time, date,
37
     * datetime, etc. formatting.
38
     */
39 3
    #[Route(
40
        path: '/v1/localization/locale',
41
        methods: [Request::METHOD_GET],
42
    )]
43
    #[OA\Response(
44
        response: 200,
45
        description: 'List of locale strings.',
46
        content: new JsonContent(
47
            type: 'array',
48
            items: new OA\Items(
49
                type: 'string',
50
                example: 'en',
51
            ),
52
            example: ['en', 'fi'],
53
        ),
54
    )]
55
    public function __invoke(): JsonResponse
56
    {
57 3
        return new JsonResponse($this->localization->getLocales());
58
    }
59
}
60