Code Coverage  | 
      ||||||||||
Classes and Traits  | 
       Functions and Methods  | 
       Lines  | 
      ||||||||
| Total |         | 
       0.00%  | 
       0 / 1  | 
               | 
       0.00%  | 
       0 / 3  | 
       CRAP |         | 
       0.00%  | 
       0 / 15  | 
      
| UpdateSubProcessAsync |         | 
       0.00%  | 
       0 / 1  | 
               | 
       0.00%  | 
       0 / 3  | 
       42 |         | 
       0.00%  | 
       0 / 15  | 
      
| handle |         | 
       0.00%  | 
       0 / 1  | 
       2 |         | 
       0.00%  | 
       0 / 9  | 
      |||
| checkError |         | 
       0.00%  | 
       0 / 1  | 
       12 |         | 
       0.00%  | 
       0 / 5  | 
      |||
| pass |         | 
       0.00%  | 
       0 / 1  | 
       6 |         | 
       0.00%  | 
       0 / 1  | 
      |||
| 1 | <?php | 
| 2 | |
| 3 | namespace Qmp\Laravel\CommandsLaravel\Middleware\Library\Monitoring; | 
| 4 | |
| 5 | use Closure; | 
| 6 | use Qmp\Laravel\CommandsLaravel\Models\CommandMonitoring; | 
| 7 | |
| 8 | class UpdateSubProcessAsync extends UpdateSubProcess | 
| 9 | { | 
| 10 | /** | 
| 11 | * Undocumented variable | 
| 12 | * | 
| 13 | * @var array | 
| 14 | */ | 
| 15 | protected $errorMessage = [ 'message' => "Subprocess fail !" ]; | 
| 16 | |
| 17 | /** | 
| 18 | * Undocumented function | 
| 19 | * | 
| 20 | * @param Closure $next | 
| 21 | * @return mixed | 
| 22 | */ | 
| 23 | public function handle($IOinterface, $next) | 
| 24 | { | 
| 25 | $this->setInterface($IOinterface); | 
| 26 | $next = parent::handle($IOinterface, $next); | 
| 27 | |
| 28 | $this->info("Update parent process monitoring"); | 
| 29 | |
| 30 | $command = CommandMonitoring::find($this->getParentId()); | 
| 31 | |
| 32 | $pass = $this->pass($command); | 
| 33 | $command->pass = $pass; | 
| 34 | $command->error = $this->checkError($command); | 
| 35 | $command->save(); | 
| 36 | |
| 37 | return $next; | 
| 38 | } | 
| 39 | |
| 40 | /** | 
| 41 | * Undocumented function | 
| 42 | * | 
| 43 | * @return mixed | 
| 44 | */ | 
| 45 | protected function checkError($command) { | 
| 46 | if($this->getError()) { | 
| 47 | return $this->getError(); | 
| 48 | } | 
| 49 | |
| 50 | if($this->pass($command)) { | 
| 51 | return null; | 
| 52 | } | 
| 53 | |
| 54 | return $this->errorMessage; | 
| 55 | } | 
| 56 | |
| 57 | /** | 
| 58 | * Undocumented function | 
| 59 | * | 
| 60 | * @param [type] $command | 
| 61 | * @return void | 
| 62 | */ | 
| 63 | protected function pass($command) { | 
| 64 | return (bool) ((bool) !collect($command->subProcess)->pluck('pass')->contains(false) && $command->error === null); | 
| 65 | } | 
| 66 | } |