Completed
Push — master ( 6a1443...a4bc0b )
by Alex
05:23 queued 03:19
created

GuzzleBridgeDriver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 32
rs 10
ccs 0
cts 15
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getResponse() 0 13 1
1
<?php
2
3
namespace Debril\RssAtomBundle\Driver;
4
5
use GuzzleHttp\Client;
6
7
/**
8
 * Class GuzzleBridgeDriver
9
 */
10
class GuzzleBridgeDriver implements HttpDriverInterface
11
{
12
    /**
13
     * @var Client
14
     */
15
    private $client;
16
17
    public function __construct(Client $client)
18
    {
19
        $this->client = $client;
20
    }
21
22
    /**
23
     * @param string    $url
24
     * @param \DateTime $lastModified
25
     *
26
     * @return HttpDriverResponse
27
     */
28
    public function getResponse($url, \DateTime $lastModified)
29
    {
30
        $ressource = $this->client->request('GET', $url);
31
32
        $response = new HttpDriverResponse();
33
        $response->setHttpCode($ressource->getStatusCode());
34
        $response->setHttpVersion($ressource->getProtocolVersion());
35
        $response->setHttpMessage($ressource->getReasonPhrase());
36
        $response->setHeaders($ressource->getHeaders());
37
        $response->setBody($ressource->getBody());
38
39
        return $response;
40
    }
41
}
42