Passed
Pull Request — 6.x (#126)
by
unknown
08:44 queued 02:10
created

ServerRequest::createRequest()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.4746

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 14
ccs 5
cts 8
cp 0.625
crap 3.4746
rs 10
1
<?php
2
3
namespace SMartins\PassportMultiauth\Facades;
4
5
use Exception;
6
use Nyholm\Psr7\Factory\Psr17Factory;
7
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
0 ignored issues
show
Bug introduced by
The type Symfony\Bridge\PsrHttpMe...actory\DiactorosFactory 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 Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
9
use Symfony\Component\HttpFoundation\Request;
10
11
class ServerRequest
12
{
13
    /**
14
     * @todo Remove deprecated DiactorosFactory in favor of PsrHttpFactory
15
     * @param Request $symfonyRequest
16
     * @return \Psr\Http\Message\RequestInterface|\Psr\Http\Message\ServerRequestInterface|\Zend\Diactoros\ServerRequest
0 ignored issues
show
Bug introduced by
The type Zend\Diactoros\ServerRequest 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...
17
     */
18 14
    public static function createRequest(Request $symfonyRequest)
19
    {
20 14
        if (class_exists(PsrHttpFactory::class)) {
21 14
            $psr17Factory = new Psr17Factory;
22
23 14
            return (new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory))
24 14
                ->createRequest($symfonyRequest);
25
        }
26
27
        if (class_exists(DiactorosFactory::class)) {
28
            return (new DiactorosFactory)->createRequest($symfonyRequest);
29
        }
30
31
        throw new Exception('Unable to resolve PSR request. Please install symfony/psr-http-message-bridge and nyholm/psr7.');
32
    }
33
}
34