Passed
Push — develop ( e3219b...3a1d34 )
by Laurent
01:38
created

GetSettings::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Company\UI\Controller\Settings;
15
16
use Company\Application\Settings\DTO\OutputSettings;
17
use Company\Application\Settings\Query\GetSettings as GetSettingsQuery;
18
use Company\Domain\Exception\SettingsNotFoundException;
19
use Core\Controller\AbstractController;
20
use Symfony\Component\HttpFoundation\Response;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Response 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...
21
22
class GetSettings extends AbstractController
23
{
24
    public function __invoke(): Response
25
    {
26
        $query = new GetSettingsQuery();
27
        /** @var OutputSettings $settings */
28
        $settings = $this->handle($query);
29
30
        if (!$settings instanceof OutputSettings) {
0 ignored issues
show
introduced by
$settings is always a sub-type of Company\Application\Settings\DTO\OutputSettings.
Loading history...
31
            throw new SettingsNotFoundException();
32
        }
33
34
        $settingsSerialized = $this->serialize($settings, ['groups' => 'read']);
35
36
        return $this->response($settingsSerialized, Response::HTTP_OK);
37
    }
38
}
39