Completed
Pull Request — 1.0.x-dev (#4)
by Patrick
02:06
created

RequestAdapterFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 17
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 14 4
1
<?php declare(strict_types=1);
2
3
namespace Starlit\Request\Authenticator\Hmac\Adapter;
4
5
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
6
use GuzzleHttp\Psr7\Request as Psr7Request;
7
use GuzzleHttp\Message\Request as Guzzle5Request;
8
9
class RequestAdapterFactory implements RequestAdapterFactoryInterface
10
{
11
    public function create($request): RequestAdapterInterface
12
    {
13
        if ($request instanceof Psr7Request) {
0 ignored issues
show
Bug introduced by
The class GuzzleHttp\Psr7\Request does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
14
            return new Psr7RequestAdapter($request);
15
        } elseif ($request instanceof SymfonyRequest) {
16
            return new SymfonyRequestAdapter($request);
17
        } elseif ($request instanceof Guzzle5Request) {
18
            return new Guzzle5RequestAdapter($request);
19
        } else {
20
            throw new \InvalidArgumentException(
21
                'Request type not supported. Only PSR-7, Symfony or Guzzle5 requests are supported.'
22
            );
23
        }
24
    }
25
}
26