@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | private function getQueryParametersFromDocBlock($tags) |
56 | 56 | { |
57 | 57 | $parameters = collect($tags) |
58 | - ->filter(function ($tag) { |
|
58 | + ->filter(function($tag) { |
|
59 | 59 | return $tag instanceof Tag && $tag->getName() === 'queryParam'; |
60 | 60 | }) |
61 | - ->mapWithKeys(function (Tag $tag) { |
|
61 | + ->mapWithKeys(function(Tag $tag) { |
|
62 | 62 | // Format: |
63 | 63 | // @queryParam <name> <"required" (optional)> <description> |
64 | 64 | // Examples: |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | list($description, $value) = $this->parseParamDescription($description, 'string'); |
85 | - if (is_null($value) && ! $this->shouldExcludeExample($tag->getContent())) { |
|
85 | + if (is_null($value) && !$this->shouldExcludeExample($tag->getContent())) { |
|
86 | 86 | $value = Str::contains($description, ['number', 'count', 'page']) |
87 | 87 | ? $this->generateDummyValue('integer') |
88 | 88 | : $this->generateDummyValue('string'); |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | private function getBodyParametersFromDocBlock($tags) |
55 | 55 | { |
56 | 56 | $parameters = collect($tags) |
57 | - ->filter(function ($tag) { |
|
57 | + ->filter(function($tag) { |
|
58 | 58 | return $tag instanceof Tag && $tag->getName() === 'bodyParam'; |
59 | 59 | }) |
60 | - ->mapWithKeys(function (Tag $tag) { |
|
60 | + ->mapWithKeys(function(Tag $tag) { |
|
61 | 61 | // Format: |
62 | 62 | // @bodyParam <name> <type> <"required" (optional)> <description> |
63 | 63 | // Examples: |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | $type = $this->normalizeParameterType($type); |
84 | 84 | list($description, $example) = $this->parseParamDescription($description, $type); |
85 | - $value = is_null($example) && ! $this->shouldExcludeExample($tag->getContent()) |
|
85 | + $value = is_null($example) && !$this->shouldExcludeExample($tag->getContent()) |
|
86 | 86 | ? $this->generateDummyValue($type) |
87 | 87 | : $example; |
88 | 88 |
@@ -9,7 +9,7 @@ |
||
9 | 9 | { |
10 | 10 | public static function routes($path = '/doc') |
11 | 11 | { |
12 | - return Route::get("$path{format?}", function (?string $format = null) { |
|
12 | + return Route::get("$path{format?}", function(?string $format = null) { |
|
13 | 13 | if ($format == '.json') { |
14 | 14 | return response( |
15 | 15 | Storage::disk('local')->get('apidoc/collection.json'), |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public static function replaceUrlParameterPlaceholdersWithValues(string $uri, array $urlParameters) |
54 | 54 | { |
55 | 55 | $matches = preg_match_all('/{.+?}/i', $uri, $parameterPaths); |
56 | - if (! $matches) { |
|
56 | + if (!$matches) { |
|
57 | 57 | return $uri; |
58 | 58 | } |
59 | 59 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | public static function deleteDirectoryAndContents($dir) |
90 | 90 | { |
91 | - $adapter = new Local(realpath(__DIR__.'/../../')); |
|
91 | + $adapter = new Local(realpath(__DIR__ . '/../../')); |
|
92 | 92 | $fs = new Filesystem($adapter); |
93 | 93 | $fs->deleteDir($dir); |
94 | 94 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $result = ''; |
102 | 102 | $padWith = str_repeat(' ', $indentationLevel); |
103 | 103 | foreach ($split as $index => $line) { |
104 | - $result .= ($index == 0 ? '' : "\n$padWith").$line; |
|
104 | + $result .= ($index == 0 ? '' : "\n$padWith") . $line; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $result; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * @param string $uri |
50 | 50 | * @param array $urlParameters Dictionary of url params and example values |
51 | 51 | * |
52 | - * @return mixed |
|
52 | + * @return string |
|
53 | 53 | */ |
54 | 54 | public static function replaceUrlParameterPlaceholdersWithValues(string $uri, array $urlParameters) |
55 | 55 | { |
@@ -40,32 +40,32 @@ |
||
40 | 40 | $collection = [ |
41 | 41 | 'variables' => [], |
42 | 42 | 'info' => [ |
43 | - 'name' => config('apidoc.postman.name') ?: config('app.name').' API', |
|
43 | + 'name' => config('apidoc.postman.name') ?: config('app.name') . ' API', |
|
44 | 44 | '_postman_id' => Uuid::uuid4()->toString(), |
45 | 45 | 'description' => config('apidoc.postman.description') ?: '', |
46 | 46 | 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json', |
47 | 47 | ], |
48 | - 'item' => $this->routeGroups->map(function ($routes, $groupName) { |
|
48 | + 'item' => $this->routeGroups->map(function($routes, $groupName) { |
|
49 | 49 | return [ |
50 | 50 | 'name' => $groupName, |
51 | 51 | 'description' => '', |
52 | - 'item' => $routes->map(function ($route) { |
|
52 | + 'item' => $routes->map(function($route) { |
|
53 | 53 | $mode = 'raw'; |
54 | 54 | |
55 | 55 | return [ |
56 | 56 | 'name' => $route['metadata']['title'] != '' ? $route['metadata']['title'] : url($route['uri']), |
57 | 57 | 'request' => [ |
58 | - 'url' => url($route['uri']).(collect($route['queryParameters'])->isEmpty() |
|
58 | + 'url' => url($route['uri']) . (collect($route['queryParameters'])->isEmpty() |
|
59 | 59 | ? '' |
60 | - : ('?'.implode('&', collect($route['queryParameters'])->map(function ($parameter, $key) { |
|
61 | - return urlencode($key).'='.urlencode($parameter['value'] ?? ''); |
|
60 | + : ('?' . implode('&', collect($route['queryParameters'])->map(function($parameter, $key) { |
|
61 | + return urlencode($key) . '=' . urlencode($parameter['value'] ?? ''); |
|
62 | 62 | })->all()))), |
63 | 63 | 'method' => $route['methods'][0], |
64 | 64 | 'header' => collect($route['headers']) |
65 | 65 | ->union([ |
66 | 66 | 'Accept' => 'application/json', |
67 | 67 | ]) |
68 | - ->map(function ($value, $header) { |
|
68 | + ->map(function($value, $header) { |
|
69 | 69 | return [ |
70 | 70 | 'key' => $header, |
71 | 71 | 'value' => $value, |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $groupedRoutes = collect($parsedRoutes) |
75 | 75 | ->groupBy('metadata.groupName') |
76 | - ->sortBy(static function ($group) { |
|
76 | + ->sortBy(static function($group) { |
|
77 | 77 | /* @var $group Collection */ |
78 | 78 | return $group->first()['metadata']['groupName']; |
79 | 79 | }, SORT_NATURAL); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $routeMethods = implode(',', $generator->getMethods($route)); |
103 | 103 | $routePath = $generator->getUri($route); |
104 | 104 | |
105 | - if (! $this->isValidRoute($route) || ! $this->isRouteVisibleForDocumentation($route->getAction())) { |
|
105 | + if (!$this->isValidRoute($route) || !$this->isRouteVisibleForDocumentation($route->getAction())) { |
|
106 | 106 | $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath)); |
107 | 107 | continue; |
108 | 108 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply'] ?? []); |
112 | 112 | $this->info(sprintf($messageFormat, 'Processed', $routeMethods, $routePath)); |
113 | 113 | } catch (\Exception $exception) { |
114 | - $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath).' - '.$exception->getMessage()); |
|
114 | + $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath) . ' - ' . $exception->getMessage()); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $action = implode('@', $action); |
131 | 131 | } |
132 | 132 | |
133 | - return ! is_callable($action) && ! is_null($action); |
|
133 | + return !is_callable($action) && !is_null($action); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | list($class, $method) = Utils::getRouteClassAndMethodNames($action); |
146 | 146 | $reflection = new ReflectionClass($class); |
147 | 147 | |
148 | - if (! $reflection->hasMethod($method)) { |
|
148 | + if (!$reflection->hasMethod($method)) { |
|
149 | 149 | return false; |
150 | 150 | } |
151 | 151 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $phpdoc = new DocBlock($comment); |
156 | 156 | |
157 | 157 | return collect($phpdoc->getTags()) |
158 | - ->filter(function ($tag) { |
|
158 | + ->filter(function($tag) { |
|
159 | 159 | return $tag->getName() === 'hideFromAPIDocumentation'; |
160 | 160 | }) |
161 | 161 | ->isEmpty(); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | // Avoid "holes" in the keys of the filtered array, by using array_values on the filtered array |
46 | 46 | $responseFileTags = array_values( |
47 | - array_filter($tags, function ($tag) { |
|
47 | + array_filter($tags, function($tag) { |
|
48 | 48 | return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile'; |
49 | 49 | }) |
50 | 50 | ); |
@@ -53,16 +53,16 @@ discard block |
||
53 | 53 | return null; |
54 | 54 | } |
55 | 55 | |
56 | - $responses = array_map(function (Tag $responseFileTag) { |
|
56 | + $responses = array_map(function(Tag $responseFileTag) { |
|
57 | 57 | preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result); |
58 | 58 | $relativeFilePath = trim($result[2]); |
59 | 59 | $filePath = storage_path($relativeFilePath); |
60 | - if (! file_exists($filePath)) { |
|
61 | - throw new \Exception('@responseFile '.$relativeFilePath.' does not exist'); |
|
60 | + if (!file_exists($filePath)) { |
|
61 | + throw new \Exception('@responseFile ' . $relativeFilePath . ' does not exist'); |
|
62 | 62 | } |
63 | 63 | $status = $result[1] ?: 200; |
64 | 64 | $content = $result[2] ? file_get_contents($filePath, true) : '{}'; |
65 | - $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}'; |
|
65 | + $json = !empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}'; |
|
66 | 66 | $merged = array_merge(json_decode($content, true), json_decode($json, true)); |
67 | 67 | |
68 | 68 | return ['content' => json_encode($merged), 'status' => (int) $status]; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $method = $controller->getMethod($methodName); |
57 | 57 | |
58 | 58 | $parsedRoute = [ |
59 | - 'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))), |
|
59 | + 'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))), |
|
60 | 60 | 'methods' => $this->getMethods($route), |
61 | 61 | 'uri' => $this->getUri($route), |
62 | 62 | ]; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | $responses = $this->fetchResponses($controller, $method, $route, $routeRules, $parsedRoute); |
83 | 83 | $parsedRoute['responses'] = $responses; |
84 | - $parsedRoute['showresponse'] = ! empty($responses); |
|
84 | + $parsedRoute['showresponse'] = !empty($responses); |
|
85 | 85 | |
86 | 86 | return $parsedRoute; |
87 | 87 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | { |
119 | 119 | $responses = $this->iterateThroughStrategies('responses', $context, [$route, $controller, $method, $rulesToApply]); |
120 | 120 | if (count($responses)) { |
121 | - return array_filter($responses, function ($response) { |
|
121 | + return array_filter($responses, function($response) { |
|
122 | 122 | return $response['content'] != null; |
123 | 123 | }); |
124 | 124 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $strategyArgs = $arguments; |
169 | 169 | $strategyArgs[] = $context; |
170 | 170 | $results = $strategy(...$strategyArgs); |
171 | - if (! is_null($results)) { |
|
171 | + if (!is_null($results)) { |
|
172 | 172 | foreach ($results as $index => $item) { |
173 | 173 | if ($stage == 'responses') { |
174 | 174 | // Responses are additive |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | // and also allows values to be overwritten |
181 | 181 | |
182 | 182 | // Don't allow overwriting if an empty value is trying to replace a set one |
183 | - if (! in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) { |
|
183 | + if (!in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) { |
|
184 | 184 | continue; |
185 | 185 | } else { |
186 | 186 | $context[$stage][$index] = $item; |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | $values = []; |
206 | 206 | |
207 | 207 | // Remove params which have no examples. |
208 | - $params = array_filter($params, function ($details) { |
|
209 | - return ! is_null($details['value']); |
|
208 | + $params = array_filter($params, function($details) { |
|
209 | + return !is_null($details['value']); |
|
210 | 210 | }); |
211 | 211 | |
212 | 212 | foreach ($params as $paramName => $details) { |
@@ -15,13 +15,13 @@ |
||
15 | 15 | public function handle() |
16 | 16 | { |
17 | 17 | $sourceOutputPath = 'resources/docs/source'; |
18 | - if (! is_dir($sourceOutputPath)) { |
|
19 | - $this->error('There is no existing documentation available at '.$sourceOutputPath.'.'); |
|
18 | + if (!is_dir($sourceOutputPath)) { |
|
19 | + $this->error('There is no existing documentation available at ' . $sourceOutputPath . '.'); |
|
20 | 20 | |
21 | 21 | return false; |
22 | 22 | } |
23 | 23 | |
24 | - $this->info('Rebuilding API documentation from '.$sourceOutputPath.'/index.md'); |
|
24 | + $this->info('Rebuilding API documentation from ' . $sourceOutputPath . '/index.md'); |
|
25 | 25 | |
26 | 26 | $writer = new Writer($this, new DocumentationConfig(config('apidoc'))); |
27 | 27 | $writer->writeHtmlDocs(); |