WebControllerService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getNotFoundResponse() 0 4 1
A __construct() 0 4 1
A getRedirectResponse() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Service;
6
7
use Psr\Http\Message\ResponseFactoryInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\ResponseFactoryInterface 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...
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\Http\Header;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Http\Header 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\Http\Status;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Http\Status 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\Router\UrlGeneratorInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Router\UrlGeneratorInterface 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
13
final class WebControllerService
14
{
15
    public function __construct(
16
        private ResponseFactoryInterface $responseFactory,
17
        private UrlGeneratorInterface $urlGenerator
18
    ) {
19
    }
20
21
    public function getRedirectResponse(string $url): ResponseInterface
22
    {
23
        return $this->responseFactory
24
            ->createResponse(Status::FOUND)
25
            ->withHeader(Header::LOCATION, $this->urlGenerator->generate($url));
26
    }
27
28
    public function getNotFoundResponse(): ResponseInterface
29
    {
30
        return $this->responseFactory
31
            ->createResponse(Status::NOT_FOUND);
32
    }
33
}
34