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.
Test Failed
Push — master ( 4c19e2...d910b5 )
by Anton
03:08
created

Reporter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B report() 0 36 4
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Util;
9
10
class Reporter
11
{
12
    const ENDPOINT = 'https://deployer.org/api/stats';
13
14
    /**
15
     * @param array $stats
16
     */
17
    public static function report($stats)
18
    {
19
        $send = function () use ($stats) {
20
            if (extension_loaded('curl')) {
21
                $body = json_encode($stats, JSON_PRETTY_PRINT);
22
                $ch = curl_init(self::ENDPOINT);
23
                curl_setopt($ch, CURLOPT_HTTPHEADER, [
24
                    'Content-Type: application/json',
25
                    'Content-Length: ' . strlen($body)
26
                ]);
27
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
28
                curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
29
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31
                curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
32
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
33
                curl_setopt($ch, CURLOPT_TIMEOUT, 5);
34
                curl_exec($ch);
35
            } else {
36
                file_get_contents(self::ENDPOINT . '?' . http_build_query($stats));
37
            }
38
        };
39
40
41
        if (extension_loaded('pcntl')) {
42
            declare(ticks = 1);
43
            $pid = pcntl_fork();
44
            if ($pid === 0) {
45
                posix_setsid();
46
                $send();
47
                exit(0);
1 ignored issue
show
Coding Style Compatibility introduced by
The method report() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
48
            }
49
        } else {
50
            $send();
51
        }
52
    }
53
}
54