Completed
Pull Request — 6.x (#123)
by
unknown
06:55
created

ServerRequest::createRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 10
ccs 5
cts 6
cp 0.8333
crap 2.0185
rs 10
1
<?php
2
3
namespace SMartins\PassportMultiauth\Facades;
4
5
use Nyholm\Psr7\Factory\Psr17Factory;
6
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
7
use Symfony\Component\HttpFoundation\Request;
8
9
class ServerRequest
10
{
11
    /**
12
     * @param Request $symfonyRequest
13
     * @return \Psr\Http\Message\RequestInterface|\Psr\Http\Message\ServerRequestInterface
14
     */
15 14
    public static function createRequest(Request $symfonyRequest)
16
    {
17 14
        if (class_exists(PsrHttpFactory::class)) {
18 14
            $psr17Factory = new Psr17Factory;
19
20 14
            return (new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory))
21 14
                ->createRequest($symfonyRequest);
22
        }
23
24
        throw new Exception('Unable to resolve PSR request. Please install symfony/psr-http-message-bridge and nyholm/psr7.');
0 ignored issues
show
Bug introduced by
The type SMartins\PassportMultiauth\Facades\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
25
    }
26
}
27