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

CurlClient   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 70
ccs 15
cts 15
cp 1
rs 10

6 Methods

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