Completed
Push — master ( 6be938...3b6271 )
by Edgar
02:01
created

CurlWrapper::read()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
namespace nstdio\notymo;
3
4
/**
5
 * Class CurlWrapper
6
 *
7
 * @package nstdio\notymo
8
 * @author  Edgar Asatryan <[email protected]>
9
 */
10
class CurlWrapper implements Connection
11
{
12
    /**
13
     * @var resource
14
     */
15
    private $stream;
16
17 6
    public function open(array $params, $socketAddress)
18
    {
19 6
        $this->stream = curl_init($socketAddress);
20
21 6
        curl_setopt_array($this->stream, $params);
22
23 6
        return $this;
24
    }
25
26 5
    public function write($option, $string)
27
    {
28 5
        curl_setopt($this->stream, $option, $string);
29 5
    }
30
31 6
    public function close()
32
    {
33 6
        if (is_resource($this->stream)) {
34 6
            curl_close($this->stream);
35 6
        }
36 6
    }
37
38 1
    public function read()
39
    {
40 1
        $response = curl_exec($this->stream);
41
42 1
        return $response;
43
    }
44
}