ForgerTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 27
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A queryForge() 0 19 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