TimeZoneController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 51 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Controller/v1/Localization/TimezoneController.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 TimezoneController
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 TimeZoneController
28
{
29 4
    public function __construct(
30
        private readonly Localization $localization,
31
    ) {
32 4
    }
33
34
    /**
35
     * Endpoint action to get list of supported timezones. This is for use to
36
     * choose what timezone your frontend application can use within its date,
37
     * time, datetime, etc. formatting.
38
     */
39 4
    #[Route(
40
        path: '/v1/localization/timezone',
41
        methods: [Request::METHOD_GET],
42
    )]
43
    #[OA\Response(
44
        response: 200,
45
        description: 'List of timezone objects.',
46
        content: new JsonContent(
47
            type: 'array',
48
            items: new OA\Items(
49
                properties: [
50
                    new OA\Property(
51
                        property: 'timezone',
52
                        description: 'Africa, America, Antarctica, Arctic, Asia, Atlantic, Australia, Europe, ' .
53
                            'Indian,Pacific,UTC.',
54
                        type: 'string',
55
                        example: 'Europe',
56
                    ),
57
                    new OA\Property(
58
                        property: 'identifier',
59
                        description: 'Timezone identifier that you can use with other libraries.',
60
                        type: 'string',
61
                        example: 'Europe/Helsinki',
62
                    ),
63
                    new OA\Property(
64
                        property: 'offset',
65
                        description: 'GMT offset of identifier.',
66
                        type: 'string',
67
                        example: 'GMT+2:00',
68
                    ),
69
                    new OA\Property(
70
                        property: 'value',
71
                        description: 'User friendly value of identifier value eg. `_` characters are replaced ' .
72
                            'by space.',
73
                        type: 'string',
74
                        example: 'Europe/Helsinki',
75
                    ),
76
                ],
77
                type: 'object'
78
            ),
79
            example: [
80
                'timezone' => 'Europe',
81
                'identifier' => 'Europe/Helsinki',
82
                'offset' => 'GMT+2:00',
83
                'value' => 'Europe/Helsinki',
84
            ],
85
        ),
86
    )]
87
    public function __invoke(): JsonResponse
88
    {
89 4
        return new JsonResponse($this->localization->getTimezones());
90
    }
91
}
92