ExitEvent   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 54
ccs 19
cts 19
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getPid() 0 4 1
A getStatus() 0 4 1
A getExitCode() 0 4 1
A getExitSignal() 0 8 2
A isNormalExit() 0 4 1
A isSignalExit() 0 4 1
1
<?php
2
3
namespace Thruster\Component\ProcessExitHandler;
4
5
use Thruster\Component\EventEmitter\Event;
6
7
/**
8
 * Class ExitEvent
9
 *
10
 * @package Thruster\Component\ProcessExitHandler
11
 * @author  Aurimas Niekis <[email protected]>
12
 */
13
class ExitEvent extends Event
14
{
15
    /**
16
     * @var int
17
     */
18
    protected $pid;
19
20
    /**
21
     * @var int
22
     */
23
    protected $status;
24
25 10
    public function __construct(int $pid, int $status)
26
    {
27 10
        $this->pid = $pid;
28 10
        $this->status = $status;
29
30 10
        parent::__construct();
31 10
    }
32
33 8
    public function getPid() : int
34
    {
35 8
        return $this->pid;
36
    }
37
38 8
    public function getStatus() : int
39
    {
40 8
        return $this->status;
41
    }
42
43 8
    public function getExitCode() : int
44
    {
45 8
        return pcntl_wexitstatus($this->getStatus());
46
    }
47
48 8
    public function getExitSignal() : int
49
    {
50 8
        if ($this->isSignalExit()) {
51 1
            return pcntl_wstopsig($this->getStatus());
52
        }
53
54 7
        return -1;
55
    }
56
57 8
    public function isNormalExit() : bool
58
    {
59 8
        return pcntl_wifexited($this->getStatus());
60
    }
61
62 8
    public function isSignalExit() : bool
63
    {
64 8
        return pcntl_wifsignaled($this->getStatus());
65
    }
66
}
67