Passed
Push — master ( 5319ee...e6b641 )
by Dani
02:13
created

Curl::setOptArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Postpay\HttpClients;
4
5
class Curl
6
{
7
    /**
8
     * @var resource Curl resource instance.
9
     */
10
    private $ch = null;
11
12
    /**
13
     * Creates a new Curl entity.
14
     */
15 12
    public function __construct()
16
    {
17 12
        $this->ch = curl_init();
18 12
    }
19
20
    /**
21
     * Set an array of options.
22
     *
23
     * @param array $options
24
     */
25 1
    public function setOptArray(array $options)
26
    {
27 1
        curl_setopt_array($this->ch, $options);
28 1
    }
29
30
    /**
31
     * Return the curl error number.
32
     *
33
     * @return int
34
     */
35 1
    public function errno()
36
    {
37 1
        return curl_errno($this->ch);
38
    }
39
40
    /**
41
     * Return the curl error message.
42
     *
43
     * @return string
44
     */
45
    public function error()
46
    {
47
        return curl_error($this->ch);
48
    }
49
50
    /**
51
     * Send a curl request.
52
     *
53
     * @return mixed
54
     */
55 1
    public function execute()
56
    {
57 1
        return curl_exec($this->ch);
58
    }
59
60
    /**
61
     * Get curl info.
62
     *
63
     * @param $name
64
     *
65
     * @return mixed
66
     */
67 1
    public function getInfo($name)
68
    {
69 1
        return curl_getinfo($this->ch, $name);
70
    }
71
72
    /**
73
     * Close the resource connection to curl.
74
     */
75 1
    public function close()
76
    {
77 1
        curl_close($this->ch);
78 1
    }
79
}
80