Passed
Pull Request — master (#579)
by Dmitriy
17:43 queued 10:10
created

SiteController::json()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller;
6
7
use App\Middleware\ApiDataWrapper;
8
use Psr\Http\Message\ResponseInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\ResponseInterface 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...
9
use Yiisoft\DataResponse\Middleware\FormatDataResponseAsJson;
0 ignored issues
show
Bug introduced by
The type Yiisoft\DataResponse\Mid...ormatDataResponseAsJson 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...
10
use Yiisoft\DataResponse\Middleware\FormatDataResponseAsXml;
0 ignored issues
show
Bug introduced by
The type Yiisoft\DataResponse\Mid...FormatDataResponseAsXml 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...
11
use Yiisoft\Yii\View\ViewRenderer;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Yii\View\ViewRenderer 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 Yiisoft\Router\Route;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Router\Route 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...
13
14
final class SiteController
15
{
16
    public function __construct(private ViewRenderer $viewRenderer)
17
    {
18
        $this->viewRenderer = $viewRenderer->withController($this);
19
    }
20
21
    #[Route(
22
        methods: ['GET'],
23
        pattern: '/',
24
        name: 'site/index',
25
    )]
26
    public function index(): ResponseInterface
27
    {
28
        return $this->viewRenderer->render('index');
29
    }
30
31
    #[Route(
32
        methods: ['GET'],
33
        pattern: '/json',
34
        name: 'site/index.json',
35
        middlewares: [
36
            FormatDataResponseAsJson::class,
37
            ApiDataWrapper::class,
38
        ],
39
    )]
40
    public function json(): ResponseInterface
41
    {
42
        return $this->viewRenderer->render('index');
43
    }
44
45
    #[Route(
46
        methods: ['GET'],
47
        pattern: '/xml',
48
        name: 'site/index.xml',
49
        middlewares: [
50
            FormatDataResponseAsXml::class,
51
            ApiDataWrapper::class,
52
        ],
53
    )]
54
    public function xml(): ResponseInterface
55
    {
56
        return $this->viewRenderer->render('index');
57
    }
58
}
59