GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Curl   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setPosts() 0 5 1
A setOutput() 0 4 1
A __construct() 0 9 2
A getResponse() 0 12 2
1
<?php
2
3
namespace Onurb\Bundle\YumlBundle\Curl;
4
5
class Curl implements CurlInterface
6
{
7
    private $curl;
8
9
    /**
10
     * @param string $url
11
     * @param resource $curl to inject an external curl_id (returned by curl_init)... for testing or whatever
12
     */
13 5
    public function __construct($url, $curl = null)
14
    {
15 5
        $this->curl = $curl ? $curl : curl_init();
16 5
        curl_setopt($this->curl, CURLOPT_URL, $url);
17
18 5
        curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
19 5
        curl_setopt($this->curl, CURLOPT_TIMEOUT, 15);
20 5
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
21 5
    }
22
23
    /**
24
     * @param array $posts
25
     */
26 1
    public function setPosts(array $posts)
27
    {
28 1
        curl_setopt($this->curl, CURLOPT_POST, count($posts));
29 1
        curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query(array_map("utf8_encode", $posts)));
30 1
    }
31
32
    /**
33
     * Write the response to a file
34
     *
35
     * @param string $filename
36
     */
37 1
    public function setOutput($filename)
38
    {
39 1
        curl_setopt($this->curl, CURLOPT_FILE, fopen($filename, 'w+'));
40 1
    }
41
42
    /**
43
     * @return mixed
44
     * @throws \Exception
45
     */
46 4
    public function getResponse()
47
    {
48 4
        $return = curl_exec($this->curl);
49 4
        if ($return === false) {
50 1
            throw new \Exception(curl_error($this->curl));
51
        }
52
53 3
        curl_close($this->curl);
54 3
        $this->curl = null;
55
56 3
        return $return;
57
    }
58
}
59