ForgerTrait::queryForge()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 13
cts 13
cp 1
rs 9.6333
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * T3Bot.
4
 *
5
 * @author Frank Nägler <[email protected]>
6
 *
7
 * @link http://www.t3bot.de
8
 * @link http://wiki.typo3.org/T3Bot
9
 */
10
namespace T3Bot\Traits;
11
12
trait ForgerTrait
13
{
14
    /**
15
     * @param string $query
16
     *
17
     * @return mixed|bool
18
     */
19 8
    protected function queryForge($query)
20
    {
21 8
        $url = "https://forge.typo3.org/{$query}.json";
22
23 8
        $ch = curl_init();
24 8
        $timeout = 5;
25 8
        curl_setopt($ch, CURLOPT_URL, $url);
26 8
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27 8
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
28 8
        $data = curl_exec($ch);
29
30 8
        $result = false;
31 8
        if (!curl_errno($ch)) {
32 8
            curl_close($ch);
33 8
            $result = json_decode($data);
34
        }
35
36 8
        return $result;
37
    }
38
}
39