Browse Source

StyleCI linting

Guy Marriott 5 years ago
parent
commit
c8f345cf66

+ 8 - 8
src/Writing/PostmanCollectionWriter.php

@@ -61,8 +61,7 @@ class PostmanCollectionWriter
             })->values()->toArray(),
         ];
 
-
-        if (!empty($this->auth)) {
+        if (! empty($this->auth)) {
             $collection['auth'] = $this->auth;
         }
 
@@ -74,6 +73,7 @@ class PostmanCollectionWriter
         $mode = 'raw';
 
         $method = $route['methods'][0];
+
         return [
             'name' => $route['metadata']['title'] != '' ? $route['metadata']['title'] : $route['uri'],
             'request' => [
@@ -96,7 +96,7 @@ class PostmanCollectionWriter
 
         // Exclude authentication headers if they're handled by Postman auth
         $authHeader = $this->getAuthHeader();
-        if (!empty($authHeader)) {
+        if (! empty($authHeader)) {
             $headers = $headers->except($authHeader);
         }
 
@@ -116,8 +116,8 @@ class PostmanCollectionWriter
 
     protected function makeUrlData($route)
     {
-        [$urlParams, $queryParams] = collect($route['urlParameters'])->partition(function($_, $key) use ($route) {
-            return Str::contains($route['uri'], '{' . $key . '}');
+        [$urlParams, $queryParams] = collect($route['urlParameters'])->partition(function ($_, $key) use ($route) {
+            return Str::contains($route['uri'], '{'.$key.'}');
         });
 
         /** @var Collection $queryParams */
@@ -126,7 +126,7 @@ class PostmanCollectionWriter
             'host' => $this->baseUrl,
             // Substitute laravel/symfony query params ({example}) to Postman style, prefixed with a colon
             'path' => preg_replace_callback('/\/{(\w+)\??}(?=\/|$)/', function ($matches) {
-                return '/:' . $matches[1];
+                return '/:'.$matches[1];
             }, $route['uri']),
             'query' => $queryParams->union($route['queryParameters'])->map(function ($parameter, $key) {
                 return [
@@ -134,7 +134,7 @@ class PostmanCollectionWriter
                     'value' => $parameter['value'],
                     'description' => $parameter['description'],
                     // Default query params to disabled if they aren't required and have empty values
-                    'disabled' => !$parameter['required'] && empty($parameter['value']),
+                    'disabled' => ! $parameter['required'] && empty($parameter['value']),
                 ];
             })->values()->toArray(),
         ];
@@ -160,7 +160,7 @@ class PostmanCollectionWriter
     protected function getAuthHeader()
     {
         $auth = $this->auth;
-        if (empty($auth) || !is_string($auth['type'] ?? null)) {
+        if (empty($auth) || ! is_string($auth['type'] ?? null)) {
             return null;
         }
 

+ 5 - 6
tests/Unit/PostmanCollectionWriterTest.php

@@ -217,7 +217,7 @@ class PostmanCollectionWriterTest extends TestCase
                 'description' => 'A not required param with a null value',
                 'required' => false,
                 'value' => null,
-            ]
+            ],
         ];
 
         $collection = $this->fakeCollection([$fakeRoute]);
@@ -265,12 +265,12 @@ class PostmanCollectionWriterTest extends TestCase
     {
         yield [
             ['type' => 'bearer', 'bearer' => ['token' => 'Test']],
-            ['Authorization' => 'Bearer Test']
+            ['Authorization' => 'Bearer Test'],
         ];
 
         yield [
             ['type' => 'apikey', 'apikey' => ['value' => 'Test', 'key' => 'X-Authorization']],
-            ['X-Authorization' => 'Test']
+            ['X-Authorization' => 'Test'],
         ];
     }
 
@@ -280,7 +280,7 @@ class PostmanCollectionWriterTest extends TestCase
             'auth' => ['type' => 'apikey', 'apikey' => [
                 'value' => 'Test',
                 'key' => 'X-Authorization',
-                'in' => 'notheader'
+                'in' => 'notheader',
             ]],
         ]);
 
@@ -292,9 +292,8 @@ class PostmanCollectionWriterTest extends TestCase
 
         $this->assertContains([
             'key' => 'X-Authorization',
-            'value' => 'Test'
+            'value' => 'Test',
         ], data_get($collection, 'item.0.item.0.request.header'));
-
     }
 
     protected function fakeRoute($path, $title = '')