Completed
Pull Request — master (#666)
by Guy
01:20
created
src/Writing/PostmanCollectionWriter.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
         $collection = [
48 48
             'variables' => [],
49 49
             'info' => [
50
-                'name' => config('apidoc.postman.name') ?: config('app.name').' API',
50
+                'name' => config('apidoc.postman.name') ?: config('app.name') . ' API',
51 51
                 '_postman_id' => Uuid::uuid4()->toString(),
52 52
                 'description' => config('apidoc.postman.description') ?: '',
53 53
                 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json',
54 54
             ],
55
-            'item' => $this->routeGroups->map(function (Collection $routes, $groupName) {
55
+            'item' => $this->routeGroups->map(function(Collection $routes, $groupName) {
56 56
                 return [
57 57
                     'name' => $groupName,
58 58
                     'description' => $routes->first()['metadata']['groupDescription'],
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             })->values()->toArray(),
62 62
         ];
63 63
 
64
-        if (! empty($this->auth)) {
64
+        if (!empty($this->auth)) {
65 65
             $collection['auth'] = $this->auth;
66 66
         }
67 67
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
         // Exclude authentication headers if they're handled by Postman auth
98 98
         $authHeader = $this->getAuthHeader();
99
-        if (! empty($authHeader)) {
99
+        if (!empty($authHeader)) {
100 100
             $headers = $headers->except($authHeader);
101 101
         }
102 102
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             ->union([
105 105
                 'Accept' => 'application/json',
106 106
             ])
107
-            ->map(function ($value, $header) {
107
+            ->map(function($value, $header) {
108 108
                 return [
109 109
                     'key' => $header,
110 110
                     'value' => $value,
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
     {
119 119
         // URL Parameters are collected by the `UrlParameters` strategies, but only make sense if they're in the route
120 120
         // definition. Filter out any URL parameters that don't appear in the URL, and assume they're query params.
121
-        [$urlParams, $queryParams] = collect($route['urlParameters'])->partition(function ($_, $key) use ($route) {
122
-            return Str::contains($route['uri'], '{'.$key.'}');
121
+        [$urlParams, $queryParams] = collect($route['urlParameters'])->partition(function($_, $key) use ($route) {
122
+            return Str::contains($route['uri'], '{' . $key . '}');
123 123
         });
124 124
 
125 125
         /** @var Collection $queryParams */
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
             'protocol' => $this->protocol,
128 128
             'host' => $this->baseUrl,
129 129
             // Substitute laravel/symfony query params ({example}) to Postman style, prefixed with a colon
130
-            'path' => preg_replace_callback('/\/{(\w+)\??}(?=\/|$)/', function ($matches) {
131
-                return '/:'.$matches[1];
130
+            'path' => preg_replace_callback('/\/{(\w+)\??}(?=\/|$)/', function($matches) {
131
+                return '/:' . $matches[1];
132 132
             }, $route['uri']),
133
-            'query' => $queryParams->union($route['queryParameters'])->map(function ($parameter, $key) {
133
+            'query' => $queryParams->union($route['queryParameters'])->map(function($parameter, $key) {
134 134
                 return [
135 135
                     'key' => $key,
136 136
                     'value' => urlencode($parameter['value']),
137 137
                     'description' => $parameter['description'],
138 138
                     // Default query params to disabled if they aren't required and have empty values
139
-                    'disabled' => ! $parameter['required'] && empty($parameter['value']),
139
+                    'disabled' => !$parameter['required'] && empty($parameter['value']),
140 140
                 ];
141 141
             })->values()->toArray(),
142 142
         ];
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             return $base;
148 148
         }
149 149
 
150
-        $base['variable'] = $urlParams->map(function ($parameter, $key) {
150
+        $base['variable'] = $urlParams->map(function($parameter, $key) {
151 151
             return [
152 152
                 'id' => $key,
153 153
                 'key' => $key,
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     protected function getAuthHeader()
163 163
     {
164 164
         $auth = $this->auth;
165
-        if (empty($auth) || ! is_string($auth['type'] ?? null)) {
165
+        if (empty($auth) || !is_string($auth['type'] ?? null)) {
166 166
             return null;
167 167
         }
168 168
 
Please login to merge, or discard this patch.