| Conditions | 2 |
| Paths | 2 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 2.0054 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | 2 | private function register(): void |
|
| 36 | { |
||
| 37 | 2 | if ($this->handlersRegistered === true) { |
|
| 38 | return; |
||
| 39 | } |
||
| 40 | |||
| 41 | 2 | pcntl_async_signals(true); |
|
| 42 | |||
| 43 | 2 | $softClose = function(): void { |
|
| 44 | 2 | $this->close(); |
|
| 45 | 2 | }; |
|
| 46 | |||
| 47 | 2 | pcntl_signal(SIGHUP, static function() { |
|
| 48 | //do nothing so it can run in background |
||
| 49 | 2 | }); |
|
| 50 | pcntl_signal(SIGINT, $softClose); |
||
| 51 | pcntl_signal(SIGABRT, $softClose); |
||
| 52 | pcntl_signal(SIGTERM, $softClose); |
||
| 53 | pcntl_signal(SIGTSTP, $softClose); |
||
| 54 | pcntl_signal(SIGALRM, $softClose); |
||
| 55 | $this->handlersRegistered = true; |
||
| 56 | } |
||
| 57 | } |
||
| 58 |