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.

Reporter   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 39
c 2
b 0
f 0
rs 10
wmc 9

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 6 1
B report() 0 26 8
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\Utility;
9
10
/**
11
 * @codeCoverageIgnore
12
 */
13
class Reporter
14
{
15
    const ENDPOINT = 'https://deployer.org/api/stats';
16
17
    public static function report(array $stats)
18
    {
19
        $pid = null;
20
        // make sure function is not disabled via php.ini "disable_functions"
21
        if (extension_loaded('pcntl') && function_exists('pcntl_fork')) {
22
            declare(ticks = 1);
23
            $pid = pcntl_fork();
24
        }
25
26
        if (is_null($pid) || $pid === -1) {
27
            // Fork fails or there is no `pcntl` extension.
28
            try {
29
                self::send($stats);
30
            } catch (\Throwable $e) {
31
                // pass
32
            }
33
        } elseif ($pid === 0) {
34
            // Child process.
35
            posix_setsid();
36
            try {
37
                self::send($stats);
38
            } catch (\Throwable $e) {
39
                // pass
40
            }
41
            // Close child process after doing job.
42
            exit(0);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
43
        }
44
    }
45
46
    private static function send(array $stats)
47
    {
48
        Httpie::post(self::ENDPOINT)
49
            ->body($stats)
50
            ->setopt(CURLOPT_SSL_VERIFYPEER, false)
51
            ->send();
52
    }
53
}
54