Completed
Push — master ( fb9cc0...a12844 )
by Johan
02:05
created

CurlClient::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Artstorm\MonkeyLearn\HttpClient;
4
5
class CurlClient
6
{
7
    /**
8
     * cURL handle.
9
     *
10
     * @var resource
11
     */
12
    protected $handle = null;
13
14
    /**
15
     * Assign dependencies.
16
     */
17 10
    public function __construct()
18
    {
19 10
        $this->handle = curl_init();
20 10
    }
21
22
    /**
23
     * Set an option on the resource handle.
24
     *
25
     * @param  int   $name
26
     * @param  mixed $value
27
     *
28
     * @return void
29
     */
30 8
    public function setOption($name, $value)
31
    {
32 8
        curl_setopt($this->handle, $name, $value);
33 8
    }
34
35
    /**
36
     * Get info about the current cURL resource.
37
     *
38
     * @return void
39
     */
40 2
    public function getInfo()
41
    {
42 2
        return curl_getinfo($this->handle);
43
    }
44
45
    /**
46
     * Execute the request.
47
     *
48
     * @return mixed
49
     */
50 6
    public function execute()
51
    {
52 6
        return curl_exec($this->handle);
53
    }
54
55
    /**
56
     * Get error from the cURL call.
57
     *
58
     * @return string
59
     */
60 4
    public function error()
61
    {
62 4
        return curl_error($this->handle);
63
    }
64
65
    /**
66
     * Close the cURL session.
67
     *
68
     * @return void
69
     */
70 4
    public function close()
71
    {
72 4
        curl_close($this->handle);
73 4
    }
74
}
75