Passed
Pull Request — master (#572)
by Dmitriy
01:31
created

ResponseFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 12
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\IO\Http\User\GetIndex\Response;
6
7
use DateTimeImmutable;
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\Data\Reader\DataReaderInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Data\Reader\DataReaderInterface 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\DataResponseFactoryInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\DataResponse\DataResponseFactoryInterface 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
12
final class ResponseFactory
13
{
14
    public function __construct(
15
        private DataResponseFactoryInterface $responseFactory,
16
    ) {
17
    }
18
19
    public function create(DataReaderInterface $dataReader): ResponseInterface
20
    {
21
        $response = [];
22
        foreach ($dataReader->read() as $user) {
23
            $response[] = new Response(
24
                $user->getLogin(),
25
                $user->getCreatedAt()->format(DateTimeImmutable::ATOM)
26
            );
27
        }
28
29
        return $this->responseFactory->createResponse([
30
            'users' => $response,
31
        ]);
32
    }
33
}
34