| Conditions | 4 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 42 | public function exec($command, &$exitCode = null): string |
||
| 43 | { |
||
| 44 | 9 | if (empty($this->workDir)) { |
|
| 45 | throw new GdaemonClientException('Empty working directory'); |
||
| 46 | 9 | } |
|
| 47 | 3 | ||
| 48 | $message = $this->binn->serialize([ |
||
| 49 | self::COMMAND_EXEC, |
||
| 50 | 6 | $command, |
|
| 51 | $this->workDir, |
||
| 52 | 6 | ]); |
|
| 53 | 6 | ||
| 54 | 6 | $read = $this->writeAndReadSocket($message); |
|
| 55 | |||
| 56 | $results = $this->binn->unserialize($read); |
||
| 57 | 6 | ||
| 58 | if ($results[0] != self::STATUS_OK) { |
||
| 59 | 6 | throw new GdaemonClientException('Execute command error: ' . isset($results[1]) ? $results[1] : 'Unknown'); |
|
| 60 | 6 | } |
|
| 61 | 6 | ||
| 62 | $exitCode = $results[1] ?? -1; |
||
| 63 | 6 | ||
| 64 | 3 | // Return command execute results |
|
| 65 | return $results[2] ?? ''; |
||
| 66 | } |
||
| 68 |