Completed
Push — develop ( 90afb9...b312ce )
by Barry
12:53
created

CurlRequest::getErrorMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Swis\PdfcrowdClient\Http;
6
7
use Swis\PdfcrowdClient\Exceptions\PdfcrowdException;
8
9
class CurlRequest implements RequestInterface
10
{
11
    private $resource;
12
13
    public function __construct()
14
    {
15
        if (!function_exists('curl_init')) {
16
            throw new PdfcrowdException('Curl php extension missing');
17
        }
18
19
        $this->resource = curl_init();
20
    }
21
22
    public function setOption($name, $value)
23
    {
24
        curl_setopt($this->resource, $name, $value);
25
    }
26
27
    public function execute()
28
    {
29
        return curl_exec($this->resource);
30
    }
31
32
    public function getInfo($name)
33
    {
34
        return curl_getinfo($this->resource, $name);
35
    }
36
37
    public function getErrorMessage()
38
    {
39
        return curl_error($this->resource);
40
    }
41
42
    public function getErrorNumber()
43
    {
44
        return curl_errno($this->resource);
45
    }
46
47
    public function close()
48
    {
49
        curl_close($this->resource);
50
    }
51
}
52