CurlClient   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getResponse() 0 16 2
1
<?php
2
namespace mikemix\Wiziq\Http;
3
4
use mikemix\Wiziq\Common\Http\ClientInterface;
5
use mikemix\Wiziq\Common\Http\Exception;
6
7
class CurlClient implements ClientInterface
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12 2
    public function getResponse($url, array $data)
13
    {
14 2
        $ch = curl_init($url);
15 2
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
16 2
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
17
18 2
        $response = curl_exec($ch);
19 2
        $error    = curl_error($ch);
20 2
        curl_close($ch);
21
22 2
        if (!$response) {
23 1
            throw Exception\InvalidResponseException::with($url, $error);
24
        }
25
26 1
        return $response;
27
    }
28
}
29