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

RequestAdapterFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 17
ccs 9
cts 9
cp 1
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 4
    public function create($request): RequestAdapterInterface
12
    {
13 4
        if ($request instanceof Psr7Request) {
14 1
            return new Psr7RequestAdapter($request);
15 3
        } elseif ($request instanceof SymfonyRequest) {
16 1
            return new SymfonyRequestAdapter($request);
17 2
        } elseif ($request instanceof Guzzle5Request) {
18 1
            return new Guzzle5RequestAdapter($request);
19
        } else {
20 1
            throw new \InvalidArgumentException(
21 1
                'Request type not supported. Only PSR-7, Symfony or Guzzle5 requests are supported.'
22
            );
23
        }
24
    }
25
}
26