Completed
Pull Request — master (#32)
by
unknown
10:03
created
src/Traits/MakesApiRequests.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
      * @param  int   $status
23 23
      * @return $this
24 24
      */
25
-    protected function seeSuccess($data = null, $status = 200)
25
+    protected function seeSuccess( $data = null, $status = 200 )
26 26
     {
27
-        $response = $this->seeSuccessResponse($data, $status);
28
-        $this->seeSuccessData($response->getData(true)['data']);
27
+        $response = $this->seeSuccessResponse( $data, $status );
28
+        $this->seeSuccessData( $response->getData( true )[ 'data' ] );
29 29
 
30 30
         return $this;
31 31
     }
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
      * @param  int   $status
38 38
      * @return $this
39 39
      */
40
-    protected function seeSuccessEquals($data = null, $status = 200)
40
+    protected function seeSuccessEquals( $data = null, $status = 200 )
41 41
     {
42
-        $response = $this->seeSuccessResponse($data, $status);
43
-        $this->seeJsonEquals($response->getData(true));
42
+        $response = $this->seeSuccessResponse( $data, $status );
43
+        $this->seeJsonEquals( $response->getData( true ) );
44 44
 
45 45
         return $this;
46 46
     }
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
      * @param  mixed $data
52 52
      * @return $this
53 53
      */
54
-    protected function seeSuccessStructure($data = null)
54
+    protected function seeSuccessStructure( $data = null )
55 55
     {
56
-        $this->seeJsonStructure([
56
+        $this->seeJsonStructure( [
57 57
             'data' => $data
58
-        ]);
58
+        ] );
59 59
 
60 60
         return $this;
61 61
     }
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
      * @param  int   $status
68 68
      * @return JsonResponse
69 69
      */
70
-    protected function seeSuccessResponse($data = null, $status = 200):JsonResponse
70
+    protected function seeSuccessResponse( $data = null, $status = 200 ):JsonResponse
71 71
     {
72
-        $response = app(Responder::class)->success($data, $status);
72
+        $response = app( Responder::class )->success( $data, $status );
73 73
 
74
-        $this->seeStatusCode($response->getStatusCode())->seeJson([
74
+        $this->seeStatusCode( $response->getStatusCode() )->seeJson( [
75 75
             'success' => true,
76 76
             'status' => $response->getStatusCode()
77
-        ])->seeJsonStructure(['data']);
77
+        ] )->seeJsonStructure( [ 'data' ] );
78 78
 
79 79
         return $response;
80 80
     }
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
      * @param  mixed $data
86 86
      * @return $this
87 87
      */
88
-    protected function seeSuccessData($data = null)
88
+    protected function seeSuccessData( $data = null )
89 89
     {
90
-        collect($data)->each(function ($value, $key) {
91
-            if (is_array($value)) {
92
-                $this->seeSuccessData($value);
90
+        collect( $data )->each( function ( $value, $key ) {
91
+            if ( is_array( $value ) ) {
92
+                $this->seeSuccessData( $value );
93 93
             } else {
94
-                $this->seeJson([$key => $value]);
94
+                $this->seeJson( [ $key => $value ] );
95 95
             }
96 96
         });
97 97
 
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
      * @param  string|array|null $attributes
105 105
      * @return array
106 106
      */
107
-    protected function getSuccessData($attributes = null)
107
+    protected function getSuccessData( $attributes = null )
108 108
     {
109
-        $rawData = $this->decodeResponseJson()['data'];
109
+        $rawData = $this->decodeResponseJson()[ 'data' ];
110 110
 
111
-        if (is_null($attributes)) {
111
+        if ( is_null( $attributes ) ) {
112 112
             return $rawData;
113
-        } elseif (is_string($attributes)) {
114
-            return array_get($rawData, $attributes);
113
+        } elseif ( is_string( $attributes ) ) {
114
+            return array_get( $rawData, $attributes );
115 115
         }
116 116
 
117
-        $data = [];
117
+        $data = [ ];
118 118
 
119
-        foreach ($attributes as $attribute) {
120
-            $data[] = array_get($rawData, $attribute);
119
+        foreach ( $attributes as $attribute ) {
120
+            $data[ ] = array_get( $rawData, $attribute );
121 121
         }
122 122
 
123 123
         return $data;
@@ -130,25 +130,25 @@  discard block
 block discarded – undo
130 130
      * @param  int|null $status
131 131
      * @return $this
132 132
      */
133
-    protected function seeError(string $error, int $status = null)
133
+    protected function seeError( string $error, int $status = null )
134 134
     {
135
-        if (! is_null($status)) {
136
-            $this->seeStatusCode($status);
135
+        if ( ! is_null( $status ) ) {
136
+            $this->seeStatusCode( $status );
137 137
         }
138 138
 
139
-        if ($this->app->config->get('responder.status_code')) {
140
-            $this->seeJson([
139
+        if ( $this->app->config->get( 'responder.status_code' ) ) {
140
+            $this->seeJson( [
141 141
                 'status' => $status
142
-            ]);
142
+            ] );
143 143
         }
144 144
 
145
-        return $this->seeJson([
145
+        return $this->seeJson( [
146 146
             'success' => false
147
-        ])->seeJsonSubset([
147
+        ] )->seeJsonSubset( [
148 148
             'error' => [
149 149
                 'code' => $error
150 150
             ]
151
-        ]);
151
+        ] );
152 152
     }
153 153
 
154 154
     /**
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * @param  int $status
158 158
      * @return $this
159 159
      */
160
-    abstract protected function seeStatusCode($status);
160
+    abstract protected function seeStatusCode( $status );
161 161
 
162 162
     /**
163 163
      * Assert that the response contains JSON.
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      * @param  bool       $negate
167 167
      * @return $this
168 168
      */
169
-    abstract public function seeJson(array $data = null, $negate = false);
169
+    abstract public function seeJson( array $data = null, $negate = false );
170 170
 
171 171
     /**
172 172
      * Assert that the JSON response has a given structure.
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      * @param  array|null $responseData
176 176
      * @return $this
177 177
      */
178
-    abstract public function seeJsonStructure(array $structure = null, $responseData = null);
178
+    abstract public function seeJsonStructure( array $structure = null, $responseData = null );
179 179
 
180 180
     /**
181 181
      * Assert that the response is a superset of the given JSON.
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      * @param  array $data
184 184
      * @return $this
185 185
      */
186
-    abstract protected function seeJsonSubset(array $data);
186
+    abstract protected function seeJsonSubset( array $data );
187 187
 
188 188
     /**
189 189
      * Assert that the response contains an exact JSON array.
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @param  array $data
192 192
      * @return $this
193 193
      */
194
-    abstract public function seeJsonEquals(array $data);
194
+    abstract public function seeJsonEquals( array $data );
195 195
 
196 196
     /**
197 197
      * Validate and return the decoded response JSON.
Please login to merge, or discard this patch.