CurlExtensionTransport   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A executeRequest() 0 17 1
1
<?php declare(strict_types=1);
2
3
namespace Fazland\SkebbyRestClient\Transport;
4
5
/**
6
 * Curl extension transport.
7
 *
8
 * @author Alessandro Chitolina <[email protected]>
9
 */
10
class CurlExtensionTransport implements TransportInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 8
    public function executeRequest(string $uri, string $body): string
16
    {
17 8
        $curl = curl_init();
18
19 8
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
20 8
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
21 8
        curl_setopt($curl, CURLOPT_TIMEOUT, 60);
22 8
        curl_setopt($curl, CURLOPT_POST, 1);
23 8
        curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
24 8
        curl_setopt($curl, CURLOPT_URL, $uri);
25
26 8
        $response = curl_exec($curl);
27
28 8
        curl_close($curl);
29
30 8
        return $response;
31
    }
32
}
33