@@ -77,7 +77,7 @@ |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * @param null $rule |
|
| 80 | + * @param string $rule |
|
| 81 | 81 | * |
| 82 | 82 | * @return static |
| 83 | 83 | */ |
@@ -34,8 +34,7 @@ discard block |
||
| 34 | 34 | public function with($parameters) |
| 35 | 35 | { |
| 36 | 36 | is_array($parameters) ? |
| 37 | - $this->parameters += $parameters : |
|
| 38 | - $this->parameters[] = $parameters; |
|
| 37 | + $this->parameters += $parameters : $this->parameters[] = $parameters; |
|
| 39 | 38 | |
| 40 | 39 | return $this; |
| 41 | 40 | } |
@@ -54,8 +53,7 @@ discard block |
||
| 54 | 53 | protected function makeDescription() |
| 55 | 54 | { |
| 56 | 55 | $description = trans()->hasForLocale($this->rule) ? |
| 57 | - trans()->get($this->rule) : |
|
| 58 | - trans()->get($this->rule, [], self::DEFAULT_LOCALE); |
|
| 56 | + trans()->get($this->rule) : trans()->get($this->rule, [], self::DEFAULT_LOCALE); |
|
| 59 | 57 | |
| 60 | 58 | return $this->replaceAttributes($description); |
| 61 | 59 | } |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function boot() |
| 17 | 17 | { |
| 18 | - $this->loadViewsFrom(__DIR__.'/../../resources/views/', 'apidoc'); |
|
| 19 | - $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'apidoc'); |
|
| 18 | + $this->loadViewsFrom(__DIR__ . '/../../resources/views/', 'apidoc'); |
|
| 19 | + $this->loadTranslationsFrom(__DIR__ . '/../../resources/lang', 'apidoc'); |
|
| 20 | 20 | |
| 21 | 21 | $this->publishes([ |
| 22 | - __DIR__.'/../../resources/lang' => $this->resource_path('lang/vendor/apidoc'), |
|
| 23 | - __DIR__.'/../../resources/views' => $this->resource_path('views/vendor/apidoc'), |
|
| 22 | + __DIR__ . '/../../resources/lang' => $this->resource_path('lang/vendor/apidoc'), |
|
| 23 | + __DIR__ . '/../../resources/views' => $this->resource_path('views/vendor/apidoc'), |
|
| 24 | 24 | ]); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function register() |
| 33 | 33 | { |
| 34 | - $this->app->singleton('apidoc.generate', function () { |
|
| 34 | + $this->app->singleton('apidoc.generate', function() { |
|
| 35 | 35 | return new GenerateDocumentation(); |
| 36 | 36 | }); |
| 37 | - $this->app->singleton('apidoc.update', function () { |
|
| 37 | + $this->app->singleton('apidoc.update', function() { |
|
| 38 | 38 | return new UpdateDocumentation(); |
| 39 | 39 | }); |
| 40 | 40 | |
@@ -53,6 +53,6 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function resource_path($path = '') |
| 55 | 55 | { |
| 56 | - return app()->basePath().'/resources'.($path ? '/'.$path : $path); |
|
| 56 | + return app()->basePath() . '/resources' . ($path ? '/' . $path : $path); |
|
| 57 | 57 | } |
| 58 | 58 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | 'description' => '', |
| 33 | 33 | 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json', |
| 34 | 34 | ], |
| 35 | - 'item' => $this->routeGroups->map(function ($routes, $groupName) { |
|
| 35 | + 'item' => $this->routeGroups->map(function($routes, $groupName) { |
|
| 36 | 36 | return [ |
| 37 | 37 | 'name' => $groupName, |
| 38 | 38 | 'description' => '', |
| 39 | - 'item' => $routes->map(function ($route) { |
|
| 39 | + 'item' => $routes->map(function($route) { |
|
| 40 | 40 | return [ |
| 41 | 41 | 'name' => $route['title'] != '' ? $route['title'] : url($route['uri']), |
| 42 | 42 | 'request' => [ |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | 'method' => $route['methods'][0], |
| 45 | 45 | 'body' => [ |
| 46 | 46 | 'mode' => 'formdata', |
| 47 | - 'formdata' => collect($route['parameters'])->map(function ($parameter, $key) { |
|
| 47 | + 'formdata' => collect($route['parameters'])->map(function($parameter, $key) { |
|
| 48 | 48 | return [ |
| 49 | 49 | 'key' => $key, |
| 50 | 50 | 'value' => isset($parameter['value']) ? $parameter['value'] : '', |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | $documentarian = new Documentarian(); |
| 46 | 46 | |
| 47 | - if (! is_dir($outputPath)) { |
|
| 48 | - $this->error('There is no generated documentation available at '.$outputPath.'.'); |
|
| 47 | + if (!is_dir($outputPath)) { |
|
| 48 | + $this->error('There is no generated documentation available at ' . $outputPath . '.'); |
|
| 49 | 49 | |
| 50 | 50 | return false; |
| 51 | 51 | } |
@@ -53,6 +53,6 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $documentarian->generate($outputPath); |
| 55 | 55 | |
| 56 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
| 56 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
| 57 | 57 | } |
| 58 | 58 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | { |
| 26 | 26 | $dispatcher = app('Dingo\Api\Dispatcher')->raw(); |
| 27 | 27 | |
| 28 | - collect($server)->map(function ($key, $value) use ($dispatcher) { |
|
| 28 | + collect($server)->map(function($key, $value) use ($dispatcher) { |
|
| 29 | 29 | $dispatcher->header($value, $key); |
| 30 | 30 | }); |
| 31 | 31 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | public function prepareMiddleware($enable = true) |
| 59 | 59 | { |
| 60 | - App::instance('middleware.disable', ! $enable); |
|
| 60 | + App::instance('middleware.disable', !$enable); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -41,7 +41,6 @@ |
||
| 41 | 41 | /** |
| 42 | 42 | * Prepares / Disables route middlewares. |
| 43 | 43 | * |
| 44 | - * @param bool $disable |
|
| 45 | 44 | * |
| 46 | 45 | * @return void |
| 47 | 46 | */ |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @param Route $route |
| 24 | 24 | * |
| 25 | - * @return mixed |
|
| 25 | + * @return string|null |
|
| 26 | 26 | */ |
| 27 | 27 | public function getDomain(Route $route) |
| 28 | 28 | { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @param Route $route |
| 34 | 34 | * |
| 35 | - * @return mixed |
|
| 35 | + * @return string |
|
| 36 | 36 | */ |
| 37 | 37 | public function getUri(Route $route) |
| 38 | 38 | { |
@@ -109,7 +109,6 @@ discard block |
||
| 109 | 109 | /** |
| 110 | 110 | * Prepares / Disables route middlewares. |
| 111 | 111 | * |
| 112 | - * @param bool $disable |
|
| 113 | 112 | * |
| 114 | 113 | * @return void |
| 115 | 114 | */ |
@@ -120,7 +119,7 @@ discard block |
||
| 120 | 119 | * |
| 121 | 120 | * @param array $tags |
| 122 | 121 | * |
| 123 | - * @return mixed |
|
| 122 | + * @return null|\Symfony\Component\HttpFoundation\Response |
|
| 124 | 123 | */ |
| 125 | 124 | protected function getDocblockResponse($tags) |
| 126 | 125 | { |
@@ -193,7 +192,7 @@ discard block |
||
| 193 | 192 | } |
| 194 | 193 | |
| 195 | 194 | /** |
| 196 | - * @param $route |
|
| 195 | + * @param Route $route |
|
| 197 | 196 | * @param $bindings |
| 198 | 197 | * @param $headers |
| 199 | 198 | * |
@@ -224,7 +223,7 @@ discard block |
||
| 224 | 223 | * @param $route |
| 225 | 224 | * @param array $bindings |
| 226 | 225 | * |
| 227 | - * @return mixed |
|
| 226 | + * @return string |
|
| 228 | 227 | */ |
| 229 | 228 | protected function addRouteModelBindings($route, $bindings) |
| 230 | 229 | { |
@@ -643,7 +642,7 @@ discard block |
||
| 643 | 642 | * @param string $rule |
| 644 | 643 | * @param string $parameter |
| 645 | 644 | * |
| 646 | - * @return array |
|
| 645 | + * @return string |
|
| 647 | 646 | */ |
| 648 | 647 | protected function parseParameters($rule, $parameter) |
| 649 | 648 | { |
@@ -674,7 +673,7 @@ discard block |
||
| 674 | 673 | } |
| 675 | 674 | |
| 676 | 675 | /** |
| 677 | - * @param $response |
|
| 676 | + * @param null|\Symfony\Component\HttpFoundation\Response $response |
|
| 678 | 677 | * |
| 679 | 678 | * @return mixed |
| 680 | 679 | */ |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $response = $docblockResponse; |
| 76 | 76 | $showresponse = true; |
| 77 | 77 | } |
| 78 | - if (! $response) { |
|
| 78 | + if (!$response) { |
|
| 79 | 79 | $transformerResponse = $this->getTransformerResponse($routeDescription['tags']); |
| 80 | 80 | if ($transformerResponse) { |
| 81 | 81 | // we have a transformer response from the docblock ( @transformer || @transformercollection ) |
@@ -83,18 +83,18 @@ discard block |
||
| 83 | 83 | $showresponse = true; |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | - if (! $response && $withResponse) { |
|
| 86 | + if (!$response && $withResponse) { |
|
| 87 | 87 | try { |
| 88 | 88 | $response = $this->getRouteResponse($route, $bindings, $headers); |
| 89 | 89 | } catch (\Exception $e) { |
| 90 | - echo "Couldn't get response for route: ".implode(',', $this->getMethods($route)).$route->uri().']: '.$e->getMessage()."\n"; |
|
| 90 | + echo "Couldn't get response for route: " . implode(',', $this->getMethods($route)) . $route->uri() . ']: ' . $e->getMessage() . "\n"; |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $content = $this->getResponseContent($response); |
| 95 | 95 | |
| 96 | 96 | return $this->getParameters([ |
| 97 | - 'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))), |
|
| 97 | + 'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))), |
|
| 98 | 98 | 'resource' => $routeGroup, |
| 99 | 99 | 'title' => $routeDescription['short'], |
| 100 | 100 | 'description' => $routeDescription['long'], |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | protected function getDocblockResponse($tags) |
| 126 | 126 | { |
| 127 | - $responseTags = array_filter($tags, function ($tag) { |
|
| 128 | - if (! ($tag instanceof Tag)) { |
|
| 127 | + $responseTags = array_filter($tags, function($tag) { |
|
| 128 | + if (!($tag instanceof Tag)) { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | // Laravel will ignore the nested array rules unless the key referenced exists and is an array |
| 188 | 188 | // So we'll to create an empty array for each array attribute |
| 189 | 189 | $values = collect($rules) |
| 190 | - ->filter(function ($values) { |
|
| 190 | + ->filter(function($values) { |
|
| 191 | 191 | return in_array('array', $values); |
| 192 | - })->map(function ($val, $key) { |
|
| 192 | + })->map(function($val, $key) { |
|
| 193 | 193 | return ['']; |
| 194 | 194 | })->all(); |
| 195 | 195 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $methods = $this->getMethods($route); |
| 213 | 213 | |
| 214 | 214 | // Split headers into key - value pairs |
| 215 | - $headers = collect($headers)->map(function ($value) { |
|
| 215 | + $headers = collect($headers)->map(function($value) { |
|
| 216 | 216 | $split = explode(':', $value); // explode to get key + values |
| 217 | 217 | $key = array_shift($split); // extract the key and keep the values in the array |
| 218 | 218 | $value = implode(':', $split); // implode values into string again |
@@ -236,8 +236,8 @@ discard block |
||
| 236 | 236 | { |
| 237 | 237 | $uri = $this->getUri($route); |
| 238 | 238 | foreach ($bindings as $model => $id) { |
| 239 | - $uri = str_replace('{'.$model.'}', $id, $uri); |
|
| 240 | - $uri = str_replace('{'.$model.'?}', $id, $uri); |
|
| 239 | + $uri = str_replace('{' . $model . '}', $id, $uri); |
|
| 240 | + $uri = str_replace('{' . $model . '?}', $id, $uri); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | return $uri; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | foreach ($reflectionMethod->getParameters() as $parameter) { |
| 303 | 303 | $parameterType = $parameter->getClass(); |
| 304 | - if (! is_null($parameterType) && class_exists($parameterType->name)) { |
|
| 304 | + if (!is_null($parameterType) && class_exists($parameterType->name)) { |
|
| 305 | 305 | $className = $parameterType->name; |
| 306 | 306 | |
| 307 | 307 | if (is_subclass_of($className, FormRequest::class)) { |
@@ -337,8 +337,8 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | protected function fancyImplode($arr, $first, $last) |
| 339 | 339 | { |
| 340 | - $arr = array_map(function ($value) { |
|
| 341 | - return '`'.$value.'`'; |
|
| 340 | + $arr = array_map(function($value) { |
|
| 341 | + return '`' . $value . '`'; |
|
| 342 | 342 | }, $arr); |
| 343 | 343 | array_push($arr, implode($last, array_splice($arr, -2))); |
| 344 | 344 | |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | protected function splitValuePairs($parameters, $first = 'is ', $last = 'or ') |
| 349 | 349 | { |
| 350 | 350 | $attribute = ''; |
| 351 | - collect($parameters)->map(function ($item, $key) use (&$attribute, $first, $last) { |
|
| 352 | - $attribute .= '`'.$item.'` '; |
|
| 351 | + collect($parameters)->map(function($item, $key) use (&$attribute, $first, $last) { |
|
| 352 | + $attribute .= '`' . $item . '` '; |
|
| 353 | 353 | if (($key + 1) % 2 === 0) { |
| 354 | 354 | $attribute .= $last; |
| 355 | 355 | } else { |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | } |
| 433 | 433 | break; |
| 434 | 434 | case 'between': |
| 435 | - if (! isset($attributeData['type'])) { |
|
| 435 | + if (!isset($attributeData['type'])) { |
|
| 436 | 436 | $attributeData['type'] = 'numeric'; |
| 437 | 437 | } |
| 438 | 438 | $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription(); |
@@ -610,8 +610,8 @@ discard block |
||
| 610 | 610 | foreach ($headers as $name => $value) { |
| 611 | 611 | $name = strtr(strtoupper($name), '-', '_'); |
| 612 | 612 | |
| 613 | - if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 614 | - $name = $prefix.$name; |
|
| 613 | + if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 614 | + $name = $prefix . $name; |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | $server[$name] = $value; |
@@ -708,8 +708,8 @@ discard block |
||
| 708 | 708 | protected function getTransformerResponse($tags) |
| 709 | 709 | { |
| 710 | 710 | try { |
| 711 | - $transFormerTags = array_filter($tags, function ($tag) { |
|
| 712 | - if (! ($tag instanceof Tag)) { |
|
| 711 | + $transFormerTags = array_filter($tags, function($tag) { |
|
| 712 | + if (!($tag instanceof Tag)) { |
|
| 713 | 713 | return false; |
| 714 | 714 | } |
| 715 | 715 | |
@@ -720,8 +720,8 @@ discard block |
||
| 720 | 720 | return false; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - $modelTag = array_first(array_filter($tags, function ($tag) { |
|
| 724 | - if (! ($tag instanceof Tag)) { |
|
| 723 | + $modelTag = array_first(array_filter($tags, function($tag) { |
|
| 724 | + if (!($tag instanceof Tag)) { |
|
| 725 | 725 | return false; |
| 726 | 726 | } |
| 727 | 727 | |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | })); |
| 730 | 730 | $tag = \array_first($transFormerTags); |
| 731 | 731 | $transformer = $tag->getContent(); |
| 732 | - if (! \class_exists($transformer)) { |
|
| 732 | + if (!\class_exists($transformer)) { |
|
| 733 | 733 | // if we can't find the transformer we can't generate a response |
| 734 | 734 | return; |
| 735 | 735 | } |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | if (version_compare(PHP_VERSION, '7.0.0') >= 0 && \is_null($type)) { |
| 746 | 746 | // we can only get the type with reflection for PHP 7 |
| 747 | 747 | if ($parameter->hasType() && |
| 748 | - ! $parameter->getType()->isBuiltin() && |
|
| 748 | + !$parameter->getType()->isBuiltin() && |
|
| 749 | 749 | \class_exists((string) $parameter->getType())) { |
| 750 | 750 | //we have a type |
| 751 | 751 | $type = (string) $parameter->getType(); |
@@ -278,7 +278,7 @@ |
||
| 278 | 278 | || (str_is($routeDomain, $generator->getDomain($route)) |
| 279 | 279 | && str_is($routePrefix, $generator->getUri($route))) |
| 280 | 280 | || in_array($middleware, $route->middleware()) |
| 281 | - ) { |
|
| 281 | + ) { |
|
| 282 | 282 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
| 283 | 283 | $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse && in_array('GET', $generator->getMethods($route))); |
| 284 | 284 | $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $this->setUserToBeImpersonated($this->option('actAsUserId')); |
| 78 | 78 | |
| 79 | - if ($routePrefix === null && $routeDomain === null && ! count($allowedRoutes) && $middleware === null) { |
|
| 79 | + if ($routePrefix === null && $routeDomain === null && !count($allowedRoutes) && $middleware === null) { |
|
| 80 | 80 | $this->error('You must provide either a route prefix, a route domain, a route or a middleware to generate the documentation.'); |
| 81 | 81 | |
| 82 | 82 | return false; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $parsedRoutes += $this->processRoutes($generator, $allowedRoutes, $routeDomain, $routePrefix, $middleware); |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | - $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function ($a, $b) { |
|
| 97 | + $parsedRoutes = collect($parsedRoutes)->groupBy('resource')->sort(function($a, $b) { |
|
| 98 | 98 | return strcmp($a->first()['resource'], $b->first()['resource']); |
| 99 | 99 | }); |
| 100 | 100 | |
@@ -109,17 +109,17 @@ discard block |
||
| 109 | 109 | private function writeMarkdown($parsedRoutes) |
| 110 | 110 | { |
| 111 | 111 | $outputPath = $this->option('output'); |
| 112 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
| 113 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
| 114 | - $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md'; |
|
| 115 | - $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md'; |
|
| 112 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
| 113 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
| 114 | + $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md'; |
|
| 115 | + $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md'; |
|
| 116 | 116 | |
| 117 | 117 | $infoText = view('apidoc::partials.info') |
| 118 | 118 | ->with('outputPath', ltrim($outputPath, 'public/')) |
| 119 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')); |
|
| 119 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')); |
|
| 120 | 120 | |
| 121 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
| 122 | - return $routeGroup->map(function ($route) { |
|
| 121 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
| 122 | + return $routeGroup->map(function($route) { |
|
| 123 | 123 | $route['output'] = (string) view('apidoc::partials.route')->with('parsedRoute', $route)->render(); |
| 124 | 124 | |
| 125 | 125 | return $route; |
@@ -139,16 +139,16 @@ discard block |
||
| 139 | 139 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 143 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 144 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $routeMatch)) { |
|
| 145 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
| 142 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 143 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 144 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $routeMatch)) { |
|
| 145 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
| 146 | 146 | if ($routeDocumentationChanged === false || $this->option('force')) { |
| 147 | 147 | if ($routeDocumentationChanged) { |
| 148 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
| 148 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
| 149 | 149 | } |
| 150 | 150 | } else { |
| 151 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
| 151 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
| 152 | 152 | $route['modified_output'] = $routeMatch[0]; |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $prependFileContents = file_exists($prependFile) |
| 162 | - ? file_get_contents($prependFile)."\n" : ''; |
|
| 162 | + ? file_get_contents($prependFile) . "\n" : ''; |
|
| 163 | 163 | $appendFileContents = file_exists($appendFile) |
| 164 | - ? "\n".file_get_contents($appendFile) : ''; |
|
| 164 | + ? "\n" . file_get_contents($appendFile) : ''; |
|
| 165 | 165 | |
| 166 | 166 | $documentarian = new Documentarian(); |
| 167 | 167 | |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | ->with('prependMd', $prependFileContents) |
| 173 | 173 | ->with('appendMd', $appendFileContents) |
| 174 | 174 | ->with('outputPath', $this->option('output')) |
| 175 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
| 175 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
| 176 | 176 | ->with('parsedRoutes', $parsedRouteOutput); |
| 177 | 177 | |
| 178 | - if (! is_dir($outputPath)) { |
|
| 178 | + if (!is_dir($outputPath)) { |
|
| 179 | 179 | $documentarian->create($outputPath); |
| 180 | 180 | } |
| 181 | 181 | |
@@ -190,23 +190,23 @@ discard block |
||
| 190 | 190 | ->with('prependMd', $prependFileContents) |
| 191 | 191 | ->with('appendMd', $appendFileContents) |
| 192 | 192 | ->with('outputPath', $this->option('output')) |
| 193 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
| 193 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
| 194 | 194 | ->with('parsedRoutes', $parsedRouteOutput); |
| 195 | 195 | |
| 196 | 196 | file_put_contents($compareFile, $compareMarkdown); |
| 197 | 197 | |
| 198 | - $this->info('Wrote index.md to: '.$outputPath); |
|
| 198 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
| 199 | 199 | |
| 200 | 200 | $this->info('Generating API HTML code'); |
| 201 | 201 | |
| 202 | 202 | $documentarian->generate($outputPath); |
| 203 | 203 | |
| 204 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
| 204 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
| 205 | 205 | |
| 206 | 206 | if ($this->option('noPostmanCollection') !== true) { |
| 207 | 207 | $this->info('Generating Postman collection'); |
| 208 | 208 | |
| 209 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
| 209 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | private function setUserToBeImpersonated($actAs) |
| 237 | 237 | { |
| 238 | - if (! empty($actAs)) { |
|
| 238 | + if (!empty($actAs)) { |
|
| 239 | 239 | if (version_compare($this->laravel->version(), '5.2.0', '<')) { |
| 240 | 240 | $userModel = config('auth.model'); |
| 241 | 241 | $user = $userModel::find($actAs); |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | ) { |
| 285 | 285 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
| 286 | 286 | $parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse && in_array('GET', $generator->getMethods($route))); |
| 287 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
| 287 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
| 288 | 288 | } else { |
| 289 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
| 289 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | private function isValidRoute(Route $route) |
| 303 | 303 | { |
| 304 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
| 304 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | $phpdoc = new DocBlock($comment); |
| 319 | 319 | |
| 320 | 320 | return collect($phpdoc->getTags()) |
| 321 | - ->filter(function ($tag) use ($route) { |
|
| 321 | + ->filter(function($tag) use ($route) { |
|
| 322 | 322 | return $tag->getName() === 'hideFromAPIDocumentation'; |
| 323 | 323 | }) |
| 324 | 324 | ->isEmpty(); |