Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 9 |
| CreateParentProcess | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 9 |
| handle | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 5 |
|||
| getCommandStructure | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Qmp\Laravel\CommandsLaravel\Middleware\Library\Monitoring; |
| 4 | |
| 5 | use Closure; |
| 6 | use Qmp\Laravel\CommandsLaravel\Middleware\Core\Middleware; |
| 7 | use Qmp\Laravel\CommandsLaravel\Models\CommandMonitoring; |
| 8 | |
| 9 | class CreateParentProcess extends Middleware |
| 10 | { |
| 11 | /** |
| 12 | * |
| 13 | */ |
| 14 | const COMMAND_STRUCT = [ |
| 15 | 'type' => null, |
| 16 | 'command' => null, |
| 17 | 'args' => null, |
| 18 | 'log' => null, |
| 19 | 'error' => null, |
| 20 | 'warning' => null, |
| 21 | 'subProcess' => [], |
| 22 | 'pass' => false, |
| 23 | 'running' => true, |
| 24 | ]; |
| 25 | |
| 26 | /** |
| 27 | * Undocumented function |
| 28 | * |
| 29 | * @param Closure $next |
| 30 | * @return mixed |
| 31 | */ |
| 32 | public function handle($IOinterface, $next) |
| 33 | { |
| 34 | $this->setInterface($IOinterface); |
| 35 | |
| 36 | $this->info('Create command monitoring'); |
| 37 | |
| 38 | $data = self::getCommandStructure(...$this->commandInformations()); |
| 39 | $this->data->id = CommandMonitoring::create($data)->_id; |
| 40 | |
| 41 | return $next($IOinterface); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Undocumented function |
| 46 | * |
| 47 | * @param [type] $signature |
| 48 | * @return array |
| 49 | */ |
| 50 | public static function getCommandStructure($type, $signature, $args, $id = null) { |
| 51 | $return = array_merge(self::COMMAND_STRUCT, [ 'type' => $type, 'command' => $signature, 'args' => $args ]); |
| 52 | |
| 53 | if($id) { |
| 54 | return ['id' => $id] + $return; |
| 55 | } |
| 56 | |
| 57 | return $return; |
| 58 | } |
| 59 | } |