/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $return = $this->larinterface->generate($this->argument('class'), $this->argument('output'), $this->argument('output_file'), $this->argument('input_file'), $this->argument('namespace'), $this->argument('name'));
     if (!is_array($return)) {
         $return = ['code' => $return];
     }
     echo json_encode($return);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $classes = $this->larinterface->getClasses();
     $this->larinterface->store();
     foreach ($classes as $class => $output) {
         $args = [$class, $output['output'], $output['output_file'], $output['input_file'], $output['namespace'], $output['name']];
         // Just in case
         $cli_args = '';
         foreach ($args as $arg) {
             $cli_args .= '"' . $arg . '" ';
         }
         $handle = popen('php artisan larinterface:encapsulate ' . $cli_args . ' 2>&1', 'r');
         $result = fread($handle, 2096);
         pclose($handle);
         if (str_contains(strtolower($result), 'php parse error')) {
             // In case of PHP parse error
             $result = json_encode(['code' => Larinterface::PARSE_ERROR]);
         }
         $result = json_decode(trim($result), true);
         if ($result['code'] === Larinterface::SUCCESS) {
             $msg = '[SUCCESS]     ' . $class;
             if ($result['comment'] > 0) {
                 $msg .= ' [MISSING: ' . $result['comment'] . ' comment block]';
             }
             $this->info($msg);
         } elseif ($result['code'] === Larinterface::EMPTY_CLASS) {
             $this->comment('No method in class ' . $class . ' to generate an Interface');
         } elseif ($result['code'] === Larinterface::NOT_CLASS) {
             $this->comment('[IGNORED]     ' . $class);
         } elseif ($result['code'] === Larinterface::NO_MODIFICATION) {
             $this->info('[UP TO DATE]  ' . $class);
         } elseif ($result['code'] === Larinterface::PARSE_ERROR) {
             $this->error('[PARSE ERROR] ' . $class);
         } else {
             $this->error('[ERROR]       Can\'t write file: ' . $result['output']);
         }
     }
 }