Skip to content

Commit 2819d00

Browse files
author
Mads Møller
authored
Merge pull request #19 from Napp/analysis-zee4E4
Apply fixes from StyleCI
2 parents fbd5437 + b96ddd3 commit 2819d00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+427
-346
lines changed

src/Auth/ApiGuard.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
use Illuminate\Http\Request;
88

99
/**
10-
* Class ApiGuard
11-
* @package Napp\Core\Api\Auth
10+
* Class ApiGuard.
1211
*/
1312
class ApiGuard extends TokenGuard
1413
{
1514
/**
1615
* @param UserProvider $provider
17-
* @param Request $request
16+
* @param Request $request
1817
*/
1918
public function __construct(UserProvider $provider, Request $request)
2019
{
@@ -25,6 +24,7 @@ public function __construct(UserProvider $provider, Request $request)
2524

2625
/**
2726
* @param array $credentials
27+
*
2828
* @return bool
2929
*/
3030
public function attempt(array $credentials = []): bool

src/Auth/AuthServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
use Illuminate\Support\ServiceProvider;
77

88
/**
9-
* Class AuthServiceProvider
10-
* @package Napp\Core\Api\Auth
9+
* Class AuthServiceProvider.
1110
*/
1211
class AuthServiceProvider extends ServiceProvider
1312
{

src/Auth/NappHttpHeaders.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
namespace Napp\Core\Api\Auth;
44

55
/**
6-
* Class NappHttpHeaders
7-
* @package Napp\Core\Api\Auth
6+
* Class NappHttpHeaders.
87
*/
98
class NappHttpHeaders
109
{

src/Controllers/ApiController.php

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
use Illuminate\Support\Facades\Response;
88

99
/**
10-
* Class ApiController
11-
* @package Napp\Core\Api\Controllers
10+
* Class ApiController.
1211
*/
1312
class ApiController extends BaseController
1413
{
@@ -40,6 +39,7 @@ public function getStatusCode()
4039

4140
/**
4241
* @param int $code
42+
*
4343
* @return $this
4444
*/
4545
public function setStatusCode($code)
@@ -51,6 +51,7 @@ public function setStatusCode($code)
5151

5252
/**
5353
* @param int $code
54+
*
5455
* @return $this
5556
*/
5657
public function setResponseCode($code)
@@ -62,6 +63,7 @@ public function setResponseCode($code)
6263

6364
/**
6465
* @param string $currentETag
66+
*
6567
* @return JsonResponse
6668
*/
6769
public function checkETag($currentETag): ?JsonResponse
@@ -76,6 +78,7 @@ public function checkETag($currentETag): ?JsonResponse
7678
/**
7779
* @param array $data
7880
* @param array $headers
81+
*
7982
* @return JsonResponse
8083
*/
8184
public function respond(array $data, array $headers = []): JsonResponse
@@ -86,6 +89,7 @@ public function respond(array $data, array $headers = []): JsonResponse
8689
/**
8790
* @param array $data
8891
* @param array $headers
92+
*
8993
* @return JsonResponse
9094
*/
9195
public function respondWithSingleObject(array $data, array $headers = []): JsonResponse
@@ -95,21 +99,23 @@ public function respondWithSingleObject(array $data, array $headers = []): JsonR
9599

96100
/**
97101
* @param string $message
102+
*
98103
* @return JsonResponse
99104
*/
100105
public function respondWithError(string $message): JsonResponse
101106
{
102107
return $this->respond([
103108
'error' => [
104109
'message' => $message,
105-
'code' => $this->getStatusCode()
106-
]
110+
'code' => $this->getStatusCode(),
111+
],
107112
]);
108113
}
109114

110115
/**
111116
* @param array $data
112117
* @param array $headers
118+
*
113119
* @return JsonResponse
114120
*/
115121
public function responseCreated(array $data, array $headers = []): JsonResponse
@@ -120,7 +126,8 @@ public function responseCreated(array $data, array $headers = []): JsonResponse
120126

121127
/**
122128
* @param string $message
123-
* @param array $headers
129+
* @param array $headers
130+
*
124131
* @return JsonResponse
125132
*/
126133
public function responseNoContent(
@@ -130,24 +137,25 @@ public function responseNoContent(
130137
return $this->setResponseCode(204)
131138
->respond(['message' => $message], $headers);
132139
}
133-
134-
/**
140+
141+
/**
135142
* @param string $message
136-
* @param array $headers
143+
* @param array $headers
144+
*
137145
* @return JsonResponse
138146
*/
139147
public function responseAccepted(
140148
string $message = 'The request was accepted for processing',
141149
array $headers = []
142150
): JsonResponse {
143-
144151
return $this->setResponseCode(202)
145152
->setStatusCode(224)
146153
->respond(['message' => $message], $headers);
147154
}
148155

149156
/**
150157
* @param array $headers
158+
*
151159
* @return JsonResponse
152160
*/
153161
public function responseNotModified(array $headers = []): JsonResponse
@@ -158,6 +166,7 @@ public function responseNotModified(array $headers = []): JsonResponse
158166

159167
/**
160168
* @param string $message
169+
*
161170
* @return \Illuminate\Http\JsonResponse
162171
*/
163172
public function responseBadRequest(string $message = 'The request failed due to an application error.'): JsonResponse
@@ -169,6 +178,7 @@ public function responseBadRequest(string $message = 'The request failed due to
169178

170179
/**
171180
* @param string $message
181+
*
172182
* @return JsonResponse
173183
*/
174184
public function responseValidationFailed(string $message = 'Validation error.'): JsonResponse
@@ -180,6 +190,7 @@ public function responseValidationFailed(string $message = 'Validation error.'):
180190

181191
/**
182192
* @param string $message
193+
*
183194
* @return JsonResponse
184195
*/
185196
public function responseUnprocessableEntity(string $message = 'The request was well-formed but was unable to be followed due to semantic errors.'): JsonResponse
@@ -191,6 +202,7 @@ public function responseUnprocessableEntity(string $message = 'The request was w
191202

192203
/**
193204
* @param string $message
205+
*
194206
* @return JsonResponse
195207
*/
196208
public function responseUnauthorized(string $message = 'Authentication credentials were missing or incorrect.'): JsonResponse
@@ -202,6 +214,7 @@ public function responseUnauthorized(string $message = 'Authentication credentia
202214

203215
/**
204216
* @param string $message
217+
*
205218
* @return JsonResponse
206219
*/
207220
public function responseUnauthorization(string $message = 'Authorization error. Requested resource is restricted.'): JsonResponse
@@ -213,6 +226,7 @@ public function responseUnauthorization(string $message = 'Authorization error.
213226

214227
/**
215228
* @param string $message
229+
*
216230
* @return JsonResponse
217231
*/
218232
public function responseForbidden(string $message = 'Forbidden.'): JsonResponse
@@ -224,6 +238,7 @@ public function responseForbidden(string $message = 'Forbidden.'): JsonResponse
224238

225239
/**
226240
* @param string $message
241+
*
227242
* @return JsonResponse
228243
*/
229244
public function responseNotFound(string $message = 'Not found.'): JsonResponse
@@ -235,6 +250,7 @@ public function responseNotFound(string $message = 'Not found.'): JsonResponse
235250

236251
/**
237252
* @param string $message
253+
*
238254
* @return JsonResponse
239255
*/
240256
public function responseClientNotFound(string $message = 'Client not found.'): JsonResponse
@@ -246,6 +262,7 @@ public function responseClientNotFound(string $message = 'Client not found.'): J
246262

247263
/**
248264
* @param string $message
265+
*
249266
* @return JsonResponse
250267
*/
251268
public function responseInternalServerError(string $message = 'Internal Server Error.'): JsonResponse
@@ -257,6 +274,7 @@ public function responseInternalServerError(string $message = 'Internal Server E
257274

258275
/**
259276
* @param string $message
277+
*
260278
* @return JsonResponse
261279
*/
262280
public function responseNotImplemented(string $message = 'The request has not been implemented.'): JsonResponse
@@ -268,6 +286,7 @@ public function responseNotImplemented(string $message = 'The request has not be
268286

269287
/**
270288
* @param string $message
289+
*
271290
* @return JsonResponse
272291
*/
273292
public function responseServiceUnavailable(string $message = 'Service Unavailable.'): JsonResponse
@@ -279,6 +298,7 @@ public function responseServiceUnavailable(string $message = 'Service Unavailabl
279298

280299
/**
281300
* @param string $message
301+
*
282302
* @return JsonResponse
283303
*/
284304
public function responseHTTPVersionNotSupported(string $message = 'This is returned if you use the HTTP protocol.'): JsonResponse
@@ -290,6 +310,7 @@ public function responseHTTPVersionNotSupported(string $message = 'This is retur
290310

291311
/**
292312
* @param Request $request
313+
*
293314
* @return int
294315
*/
295316
public function getLimit(Request $request): int
@@ -305,6 +326,7 @@ public function getLimit(Request $request): int
305326

306327
/**
307328
* @param Request $request
329+
*
308330
* @return int
309331
*/
310332
protected function getOffset(Request $request): int
@@ -313,9 +335,10 @@ protected function getOffset(Request $request): int
313335
}
314336

315337
/**
316-
* Get the page for pagination
338+
* Get the page for pagination.
317339
*
318340
* @param Request $request
341+
*
319342
* @return int
320343
*/
321344
public function getPage(Request $request): int
@@ -324,9 +347,10 @@ public function getPage(Request $request): int
324347
}
325348

326349
/**
327-
* Get the page size for pagination
350+
* Get the page size for pagination.
328351
*
329352
* @param Request $request
353+
*
330354
* @return int
331355
*/
332356
public function getPageSize(Request $request): int

src/Controllers/ApiInternalController.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
use Illuminate\Auth\AuthManager;
66
use Illuminate\Http\JsonResponse;
77
use Illuminate\Http\Response;
8+
use Napp\Core\Api\Auth\NappHttpHeaders;
89
use Napp\Core\Api\Exceptions\Exceptions\ApiInternalCallException;
910
use Napp\Core\Api\Router\Router;
10-
use Napp\Core\Api\Auth\NappHttpHeaders;
1111

1212
/**
13-
* Class ApiInternalController
14-
* @package Napp\Core\Api\Controllers
13+
* Class ApiInternalController.
1514
*/
1615
class ApiInternalController extends BaseController
1716
{
@@ -27,7 +26,7 @@ class ApiInternalController extends BaseController
2726

2827
/**
2928
* @param AuthManager $auth
30-
* @param Router $router
29+
* @param Router $router
3130
*/
3231
public function __construct(AuthManager $auth, Router $router)
3332
{
@@ -45,7 +44,8 @@ public function getInternalRouter(): Router
4544

4645
/**
4746
* @param string $uri
48-
* @param array $headers
47+
* @param array $headers
48+
*
4949
* @return array
5050
*/
5151
public function get(string $uri, array $headers = []): array
@@ -57,8 +57,9 @@ public function get(string $uri, array $headers = []): array
5757

5858
/**
5959
* @param string $uri
60-
* @param array $data
61-
* @param array $headers
60+
* @param array $data
61+
* @param array $headers
62+
*
6263
* @return array
6364
*/
6465
public function post(string $uri, array $data, array $headers = []): array
@@ -70,8 +71,9 @@ public function post(string $uri, array $data, array $headers = []): array
7071

7172
/**
7273
* @param string $uri
73-
* @param array $data
74-
* @param array $headers
74+
* @param array $data
75+
* @param array $headers
76+
*
7577
* @return array
7678
*/
7779
public function put(string $uri, array $data, array $headers = []): array
@@ -83,7 +85,8 @@ public function put(string $uri, array $data, array $headers = []): array
8385

8486
/**
8587
* @param string $uri
86-
* @param array $headers
88+
* @param array $headers
89+
*
8790
* @return array
8891
*/
8992
public function delete(string $uri, array $headers = []): array
@@ -95,20 +98,23 @@ public function delete(string $uri, array $headers = []): array
9598

9699
/**
97100
* @param array $headers
101+
*
98102
* @return array
99103
*/
100104
protected function getInternalCallHeaders(array $headers): array
101105
{
102106
return array_merge($headers, [
103-
NappHttpHeaders::NAPP_API_CALL_TYPE => 'internal',
107+
NappHttpHeaders::NAPP_API_CALL_TYPE => 'internal',
104108
NappHttpHeaders::NAPP_AUTH_GLOBAL_USER_ID => $this->auth->guard()->id(),
105109
]);
106110
}
107111

108112
/**
109113
* @param Response|JsonResponse $response
110-
* @return array
114+
*
111115
* @throws ApiInternalCallException
116+
*
117+
* @return array
112118
*/
113119
protected function formatResponse($response): array
114120
{

0 commit comments

Comments
 (0)