Total Complexity | 5 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class PcntlSignals |
||
14 | { |
||
15 | /** @var int[] */ |
||
16 | protected $signals; |
||
17 | |||
18 | /** |
||
19 | * PcntlSignals constructor. |
||
20 | * |
||
21 | * @param int[] $signals |
||
22 | */ |
||
23 | public function __construct(array $signals) |
||
24 | { |
||
25 | $this->signals = $signals; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * block signals using pcntl_sigprocmask |
||
30 | * This is not covered on test because it creates a php system call |
||
31 | * |
||
32 | * @return bool |
||
33 | */ |
||
34 | public function block(): bool |
||
35 | { |
||
36 | return pcntl_sigprocmask(SIG_BLOCK, $this->signals); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * unblock signals using pcntl_sigprocmask |
||
41 | * This is not covered on test because it creates a php system call |
||
42 | * |
||
43 | * @return bool |
||
44 | */ |
||
45 | public function unblock(): bool |
||
46 | { |
||
47 | return pcntl_sigprocmask(SIG_UNBLOCK, $this->signals); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * wait for blocked signals using pcntl_sigtimedwait |
||
52 | * This is not covered on test because it creates a php system call |
||
53 | * |
||
54 | * @param int $seconds Numbers of seconds to wait |
||
55 | * @return int |
||
56 | */ |
||
57 | public function wait(int $seconds): int |
||
61 | } |
||
62 | } |
||
63 |