CurlExtensionTransport::executeRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 11
cts 11
cp 1
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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