| Conditions | 2 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2.0438 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 54 | 97 | protected function osProcessIsRunning(string $needle): bool |
|
| 55 | { |
||
| 56 | // get process status. the "-ww"-option is important to get the full output! |
||
|
1 ignored issue
–
show
|
|||
| 57 | 97 | exec('ps aux -ww', $process_status); |
|
| 58 | |||
| 59 | |||
| 60 | // search $needle in process status |
||
|
1 ignored issue
–
show
|
|||
| 61 | 97 | $result = array_filter( |
|
| 62 | 97 | $process_status, |
|
| 63 | function ($var) use ($needle) { |
||
| 64 | return strpos($var, $needle); |
||
| 65 | 97 | } |
|
| 66 | ); |
||
| 67 | |||
| 68 | // if the result is not empty, the needle exists in running processes |
||
|
1 ignored issue
–
show
|
|||
| 69 | 97 | if (!empty($result)) { |
|
| 70 | return true; |
||
| 71 | } |
||
| 72 | |||
| 73 | 97 | return false; |
|
| 74 | } |
||
| 76 |