AsyncTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A asyncRun() 0 15 2
1
<?php
2
namespace App\BxConsole;
3
4
use Symfony\Component\Console\Command\Command;
5
6
trait AsyncTrait {
7
8
    public static function asyncRun($logFile = '') {
9
10
        $binPath = EnvHelper::getBinPath();
11
        /** @var Command $command */
12
        $command = new self();
13
14
        if(empty($logFile)) {
15
            $logFile = '/dev/null';
16
        } else {
17
            $logFile = $_ENV['APP_CMD_LOG_PATH'] . $logFile;
18
        }
19
20
        $cmd = sprintf("nohup %s %s > %s 2>&1 &", $binPath, $command->getName(), $logFile);
21
22
        exec($cmd);
23
    }
24
}