CurlRequest   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 29.17%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 37
ccs 7
cts 24
cp 0.2917
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setUrl() 0 6 2
A setOptionArray() 0 5 2
A setOption() 0 3 1
A execute() 0 3 1
A getInfo() 0 3 1
A close() 0 3 1
1
<?php
2
3
namespace Zenapply\Request;
4
5
class CurlRequest implements HttpRequest
6
{
7
    private $handle = null;
8
9 3
    public function __construct($url) {
10 3
        $this->setUrl($url);
11 3
    }
12
13 3
    public function setUrl($url) {
14 3
        if($this->handle !== null){
15
            $this->close();
16
        }
17 3
        $this->handle = curl_init($url);
18 3
    }
19
20
    public function setOptionArray($array) {
21
        foreach ($array as $key => $value) {
22
            $this->setOption($key,$value);
23
        }
24
    }
25
26
    public function setOption($name, $value) {
27
        curl_setopt($this->handle, $name, $value);
28
    }
29
30
    public function execute() {
31
        return curl_exec($this->handle);
32
    }
33
34
    public function getInfo($name) {
35
        return curl_getinfo($this->handle, $name);
36
    }
37
38
    public function close() {
39
        curl_close($this->handle);
40
    }
41
}