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::setPosts()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
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