Completed
Pull Request — master (#40)
by Ulrich
01:53
created

SwaggerRequester::send()   C

Complexity

Conditions 10
Paths 160

Size

Total Lines 85

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 85
rs 6.0606
c 0
b 0
f 0
cc 10
nc 160
nop 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace ByJG\Swagger;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\ClientInterface;
7
use Psr\Http\Message\RequestInterface;
8
use Psr\Http\Message\ResponseInterface;
9
10
/**
11
 * Request handler based on a Guzzle client.
12
 */
13
class SwaggerRequester extends AbstractRequester
14
{
15
    /**
16
     * @var ClientInterface
17
     */
18
    protected $guzzleHttpClient;
19
20
    public function __construct()
21
    {
22
        $this->guzzleHttpClient = new Client(['headers' => ['User-Agent' => 'Swagger Test']]);
23
    }
24
25
    protected function handleRequest(RequestInterface $request)
26
    {
27
        return $this->guzzleHttpClient->send($request, ['allow_redirects' => false]);
28
    }
29
}
30