MailxpertCurl::setoptArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * sources.
4
 * Date: 14/08/15
5
 */
6
7
namespace Mailxpert\HttpClients;
8
9
/**
10
 * Class MailxpertCurl
11
 *
12
 * Abstraction for the procedural curl elements so that curl can be mocked and the implementation can be tested.
13
 *
14
 * @package Mailxpert
15
 */
16
class MailxpertCurl
17
{
18
    /**
19
     * @var resource Curl resource instance
20
     */
21
    protected $curl;
22
23
    /**
24
     * Make a new curl reference instance
25
     */
26
    public function init()
27
    {
28
        $this->curl = curl_init();
29
    }
30
31
    /**
32
     * Set a curl option
33
     *
34
     * @param string $key
35
     * @param mixed  $value
36
     */
37
    public function setopt($key, $value)
38
    {
39
        curl_setopt($this->curl, $key, $value);
40
    }
41
42
    /**
43
     * Set an array of options to a curl resource
44
     *
45
     * @param array $options
46
     */
47
    public function setoptArray(array $options)
48
    {
49
        curl_setopt_array($this->curl, $options);
50
    }
51
52
    /**
53
     * Send a curl request
54
     *
55
     * @return mixed
56
     */
57
    public function exec()
58
    {
59
        return curl_exec($this->curl);
60
    }
61
62
    /**
63
     * Return the curl error number
64
     *
65
     * @return int
66
     */
67
    public function errno()
68
    {
69
        return curl_errno($this->curl);
70
    }
71
72
    /**
73
     * Return the curl error message
74
     *
75
     * @return string
76
     */
77
    public function error()
78
    {
79
        return curl_error($this->curl);
80
    }
81
82
    /**
83
     * Get info from a curl reference
84
     *
85
     * @param string $type
86
     *
87
     * @return mixed
88
     */
89
    public function getinfo($type)
90
    {
91
        return curl_getinfo($this->curl, $type);
92
    }
93
94
    /**
95
     * Get the currently installed curl version
96
     *
97
     * @return array
98
     */
99
    public function version()
100
    {
101
        return curl_version();
102
    }
103
104
    /**
105
     * Close the resource connection to curl
106
     */
107
    public function close()
108
    {
109
        curl_close($this->curl);
110
    }
111
}
112