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

CurlRequest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A setOption() 0 4 1
A execute() 0 4 1
A getInfo() 0 4 1
A getErrorMessage() 0 4 1
A getErrorNumber() 0 4 1
A close() 0 4 1
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