Progress   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A started() 0 7 2
A exited() 0 9 2
1
<?php
2
/**
3
 * Progress statusing
4
 * User: moyo
5
 * Date: 03/02/2018
6
 * Time: 2:27 PM
7
 */
8
9
namespace Carno\Process;
10
11
class Progress
12
{
13
    /**
14
     * @var array
15
     */
16
    private static $named = [];
17
18
    /**
19
     * @param int $pid
20
     * @param string $name
21
     */
22
    public static function started(int $pid, string $name = null) : void
23
    {
24
        $name && self::$named[$pid] = $name;
25
26
        logger('process')->info('Process started', [
27
            'pid' => $pid,
28
            'name' => $name ?? (self::$named[$pid] ?? 'unknown'),
29
        ]);
30
    }
31
32
    /**
33
     * @param int $pid
34
     * @param int $sig
35
     * @param int $code
36
     * @param string $name
37
     */
38
    public static function exited(int $pid, int $sig, int $code, string $name = null) : void
39
    {
40
        $name && self::$named[$pid] = $name;
41
42
        logger('process')->info('Process exited', [
43
            'pid' => $pid,
44
            'signal' => $sig,
45
            'code' => $code,
46
            'name' => $name ?? (self::$named[$pid] ?? 'unknown'),
47
        ]);
48
    }
49
}
50