diff --git a/src/Auth/ApiGuard.php b/src/Auth/ApiGuard.php index 22a615c..18b90ab 100644 --- a/src/Auth/ApiGuard.php +++ b/src/Auth/ApiGuard.php @@ -2,9 +2,9 @@ namespace Napp\Core\Api\Auth; +use Illuminate\Http\Request; use Illuminate\Auth\TokenGuard; use Illuminate\Contracts\Auth\UserProvider; -use Illuminate\Http\Request; /** * Class ApiGuard. diff --git a/src/Controllers/ApiController.php b/src/Controllers/ApiController.php index 0d4fbc6..3bce821 100644 --- a/src/Controllers/ApiController.php +++ b/src/Controllers/ApiController.php @@ -2,8 +2,8 @@ namespace Napp\Core\Api\Controllers; -use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Response; /** diff --git a/src/Controllers/ApiInternalController.php b/src/Controllers/ApiInternalController.php index 98bca19..06ea8a7 100644 --- a/src/Controllers/ApiInternalController.php +++ b/src/Controllers/ApiInternalController.php @@ -2,12 +2,12 @@ namespace Napp\Core\Api\Controllers; +use Illuminate\Http\Response; use Illuminate\Auth\AuthManager; +use Napp\Core\Api\Router\Router; use Illuminate\Http\JsonResponse; -use Illuminate\Http\Response; use Napp\Core\Api\Auth\NappHttpHeaders; use Napp\Core\Api\Exceptions\Exceptions\ApiInternalCallException; -use Napp\Core\Api\Router\Router; /** * Class ApiInternalController. diff --git a/src/Controllers/ApiProxyController.php b/src/Controllers/ApiProxyController.php index e0419da..546556b 100644 --- a/src/Controllers/ApiProxyController.php +++ b/src/Controllers/ApiProxyController.php @@ -2,8 +2,8 @@ namespace Napp\Core\Api\Controllers; -use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Http\JsonResponse; /** * Class ApiProxyController. @@ -45,7 +45,7 @@ private function callApi(string $endpoint, Request $request) } if (false === empty($arguments)) { - $callArguments = [$url.'?'.http_build_query($arguments)]; + $callArguments = [$url . '?' . http_build_query($arguments)]; } return $this->{$requestMethod}(...$callArguments); diff --git a/src/Controllers/BaseController.php b/src/Controllers/BaseController.php index 4d02603..02a9cef 100644 --- a/src/Controllers/BaseController.php +++ b/src/Controllers/BaseController.php @@ -2,10 +2,10 @@ namespace Napp\Core\Api\Controllers; -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; +use Illuminate\Routing\Controller; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; -use Illuminate\Routing\Controller; +use Illuminate\Foundation\Auth\Access\AuthorizesRequests; /** * Class BaseController. diff --git a/src/Exceptions/NappApiHandler.php b/src/Exceptions/NappApiHandler.php index c4ea623..550e314 100644 --- a/src/Exceptions/NappApiHandler.php +++ b/src/Exceptions/NappApiHandler.php @@ -3,10 +3,10 @@ namespace Napp\Core\Api\Exceptions; use Illuminate\Http\JsonResponse; -use Napp\Core\Api\Exceptions\Exceptions\Exception as NappException; -use Napp\Core\Api\Exceptions\Renderer\DebugRenderer; use Napp\Core\Api\Exceptions\Renderer\Renderer; +use Napp\Core\Api\Exceptions\Renderer\DebugRenderer; use Napp\Core\Api\Exceptions\Renderer\RendererInterface; +use Napp\Core\Api\Exceptions\Exceptions\Exception as NappException; /** * Class NappApiHandler. diff --git a/src/Requests/ApiRequest.php b/src/Requests/ApiRequest.php index e5034f4..41e8b1c 100644 --- a/src/Requests/ApiRequest.php +++ b/src/Requests/ApiRequest.php @@ -2,13 +2,13 @@ namespace Napp\Core\Api\Requests; -use Illuminate\Contracts\Validation\Validator; use Illuminate\Foundation\Http\FormRequest; -use Napp\Core\Api\Exceptions\Exceptions\ApiInternalCallValidationException; -use Napp\Core\Api\Exceptions\Exceptions\InvalidFieldException; -use Napp\Core\Api\Exceptions\Exceptions\ValidationException; +use Illuminate\Contracts\Validation\Validator; use Napp\Core\Api\Transformers\ApiTransformer; use Napp\Core\Api\Transformers\TransformerInterface; +use Napp\Core\Api\Exceptions\Exceptions\ValidationException; +use Napp\Core\Api\Exceptions\Exceptions\InvalidFieldException; +use Napp\Core\Api\Exceptions\Exceptions\ApiInternalCallValidationException; /** * Class ApiRequest. @@ -57,7 +57,7 @@ protected function validateInputFields(): void $rules = $this->rules(); if (false === empty(array_diff_key($input, $rules))) { $exception = new InvalidFieldException(); - $exception->statusMessage = $exception->statusMessage.': '.implode(',', array_keys(array_diff_key($input, $rules))); + $exception->statusMessage = $exception->statusMessage . ': ' . implode(',', array_keys(array_diff_key($input, $rules))); throw $exception; } @@ -72,7 +72,7 @@ protected function transformInput(): array * Remove input fields like _method, _token, etc. */ $input = array_filter($this->input(), function ($key) { - return !starts_with($key, '_'); + return ! starts_with($key, '_'); }, ARRAY_FILTER_USE_KEY); return $this->getTransformer()->transformInput($input); @@ -113,7 +113,7 @@ protected function handleApiCallFailedValidation(Validator $validator) { $message = $validator->messages()->first(); $exception = new ValidationException(); - $exception->statusMessage = $exception->statusMessage.': '.$message; + $exception->statusMessage = $exception->statusMessage . ': ' . $message; $exception->validation = $this->transformValidationOutput($validator); throw $exception; diff --git a/src/Router/Provider/RouterServiceProvider.php b/src/Router/Provider/RouterServiceProvider.php index a99c371..10143d9 100644 --- a/src/Router/Provider/RouterServiceProvider.php +++ b/src/Router/Provider/RouterServiceProvider.php @@ -2,8 +2,8 @@ namespace Napp\Core\Api\Router\Provider; -use Illuminate\Support\ServiceProvider as BaseProvider; use Napp\Core\Api\Router\Router; +use Illuminate\Support\ServiceProvider as BaseProvider; /** * Class RouterServiceProvider. diff --git a/src/Router/Router.php b/src/Router/Router.php index 77690da..71899fb 100644 --- a/src/Router/Router.php +++ b/src/Router/Router.php @@ -2,8 +2,8 @@ namespace Napp\Core\Api\Router; -use Illuminate\Foundation\Application; use Illuminate\Http\Request; +use Illuminate\Foundation\Application; use Illuminate\Routing\Router as LaravelRouter; /** @@ -237,7 +237,7 @@ private function transformHeadersToServerVariables($headers) $server = []; foreach ($headers as $headerType => $headerValue) { - $headerType = 'HTTP_'.$headerType; + $headerType = 'HTTP_' . $headerType; $server[$headerType] = $headerValue; } diff --git a/src/Transformers/ApiTransformer.php b/src/Transformers/ApiTransformer.php index 24b4c93..893a816 100644 --- a/src/Transformers/ApiTransformer.php +++ b/src/Transformers/ApiTransformer.php @@ -2,12 +2,12 @@ namespace Napp\Core\Api\Transformers; -use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Support\Str; +use Illuminate\Support\Collection; +use Illuminate\Pagination\Paginator; use Illuminate\Database\Eloquent\Model; +use Illuminate\Contracts\Support\Arrayable; use Illuminate\Pagination\LengthAwarePaginator; -use Illuminate\Pagination\Paginator; -use Illuminate\Support\Collection; -use Illuminate\Support\Str; /** * Class ApiTransformer. @@ -110,7 +110,7 @@ public function transformOutputKeys(array $data): array protected function transformAttributes(array $output, array $data): array { foreach ($data as $key => $value) { - if (true === $this->strict && !$this->isMapped($key)) { + if (true === $this->strict && ! $this->isMapped($key)) { continue; } @@ -131,7 +131,7 @@ protected function transformRelationships(array $output, Model $data): array /** @var Model $data */ $relationships = $data->getRelations(); foreach ($relationships as $relationshipName => $relationship) { - if (true === $this->strict && !$this->isMapped($relationshipName)) { + if (true === $this->strict && ! $this->isMapped($relationshipName)) { continue; } @@ -249,7 +249,7 @@ protected function convertValueType(string $key, $value) ? $this->apiMapping[$key]['dataType'] : 'unknown'; - foreach (static::normalizeType($type) as list($method, $parameters)) { + foreach (static::normalizeType($type) as [$method, $parameters]) { if (true === empty($method)) { return $value; } @@ -285,7 +285,7 @@ protected static function parseStringDataType($type): array // easy {data-type}:{parameters} formatting convention. For instance the // data-type "float:3" states that the value will be converted to a float with 3 decimals. if (mb_strpos($type, ':') !== false) { - list($dataType, $parameter) = explode(':', $type, 2); + [$dataType, $parameter] = explode(':', $type, 2); $parameters = static::parseParameters($parameter); } diff --git a/src/Transformers/NoneTransformer.php b/src/Transformers/NoneTransformer.php index 16f3070..9a5bebb 100644 --- a/src/Transformers/NoneTransformer.php +++ b/src/Transformers/NoneTransformer.php @@ -2,8 +2,8 @@ namespace Napp\Core\Api\Transformers; -use Illuminate\Contracts\Support\Arrayable; use Illuminate\Support\Arr; +use Illuminate\Contracts\Support\Arrayable; /** * Class NoneTransformer. diff --git a/src/Validation/ValidateTrait.php b/src/Validation/ValidateTrait.php index 490e29d..e0160fe 100644 --- a/src/Validation/ValidateTrait.php +++ b/src/Validation/ValidateTrait.php @@ -2,9 +2,9 @@ namespace Napp\Core\Api\Validation; -use Illuminate\Contracts\Validation\Factory as ValidatorFactory; use Illuminate\Contracts\Validation\Validator; use Napp\Core\Api\Exceptions\Exceptions\ValidationException; +use Illuminate\Contracts\Validation\Factory as ValidatorFactory; /** * Trait ValidateTrait. @@ -27,7 +27,7 @@ public static function validate(array $attributes, array $rules) $message = $validator->messages()->first(); $exception = new ValidationException(); - $exception->statusMessage = $exception->statusMessage.': '.$message; + $exception->statusMessage = $exception->statusMessage . ': ' . $message; $exception->validation = $validator->messages(); throw $exception;