1 | <?php |
||
13 | class GenerateDocumentation extends Command |
||
14 | { |
||
15 | /** |
||
16 | * The name and signature of the console command. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $signature = 'api:generate |
||
21 | {--output=public/docs : The output path for the generated documentation} |
||
22 | {--routePrefix= : The route prefix to use for generation} |
||
23 | {--routes=* : The route names to use for generation} |
||
24 | {--actAsUserId= : The user ID to use for API response calls} |
||
25 | {--router=laravel : The router to be used (Laravel or Dingo)} |
||
26 | {--bindings= : Route Model Bindings} |
||
27 | '; |
||
28 | |||
29 | /** |
||
30 | * The console command description. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $description = 'Generate your API documentation from existing Laravel routes.'; |
||
35 | |||
36 | /** |
||
37 | * Create a new command instance. |
||
38 | * |
||
39 | * @return void |
||
|
|||
40 | */ |
||
41 | public function __construct() |
||
45 | |||
46 | /** |
||
47 | * Execute the console command. |
||
48 | * |
||
49 | * @return false|null |
||
50 | */ |
||
51 | public function handle() |
||
79 | |||
80 | /** |
||
81 | * @param Collection $parsedRoutes |
||
82 | * |
||
83 | * @return void |
||
84 | */ |
||
85 | private function writeMarkdown($parsedRoutes) |
||
107 | |||
108 | /** |
||
109 | * @return array |
||
110 | */ |
||
111 | private function getBindings() |
||
126 | |||
127 | /** |
||
128 | * @param $actAs |
||
129 | */ |
||
130 | private function setUserToBeImpersonated($actAs) |
||
144 | |||
145 | /** |
||
146 | * @return mixed |
||
147 | */ |
||
148 | private function getRoutes() |
||
156 | |||
157 | /** |
||
158 | * @param AbstractGenerator $generator |
||
159 | * @param $allowedRoutes |
||
160 | * @param $routePrefix |
||
161 | * |
||
162 | * @return array |
||
163 | */ |
||
164 | private function processLaravelRoutes(AbstractGenerator $generator, $allowedRoutes, $routePrefix) |
||
182 | |||
183 | /** |
||
184 | * @param AbstractGenerator $generator |
||
185 | * @param $allowedRoutes |
||
186 | * @param $routePrefix |
||
187 | * |
||
188 | * @return array |
||
189 | */ |
||
190 | private function processDingoRoutes(AbstractGenerator $generator, $allowedRoutes, $routePrefix) |
||
204 | |||
205 | /** |
||
206 | * @param $route |
||
207 | * @return bool |
||
208 | */ |
||
209 | private function isValidRoute($route) |
||
213 | } |
||
214 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.