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

CurlWrapper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 35
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A open() 0 8 1
A write() 0 4 1
A close() 0 6 2
A read() 0 6 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
}