| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Desemax\ArtisanUI\Http\Resources; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Illuminate\Http\Resources\Json\JsonResource; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Symfony\Component\Console\Input\InputArgument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Symfony\Component\Console\Input\InputOption; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | class Command extends JsonResource | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      * Transform the resource into an array. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      * @param  \Illuminate\Http\Request  $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     public function toArray($request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |             'name' => $this->getName(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |             'help' => $this->getHelp(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             'description' => $this->getDescription(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             'arguments' => $this->getArguments(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |             'options' => $this->getOptions(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |     protected function getArguments() | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |         return array_map(function (InputArgument $inputArgument) { | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |             return [ | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |                 'name' => $inputArgument->getName(), | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |                 'description' => $inputArgument->getDescription(), | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |                 'default' => $inputArgument->getDefault(), | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |                 'required' => $inputArgument->isRequired(), | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |             ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |         }, $this->getDefinition()->getArguments()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     protected function getOptions() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         return array_map(function (InputOption $inputOption) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                 'name' => $inputOption->getName(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |                 'description' => $inputOption->getDescription(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |                 'shortcut' => $inputOption->getShortcut(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                 'default' => $inputOption->getDefault(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         }, $this->getDefinition()->getOptions()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 51 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 52 |  |  |  |