Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #23

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Auth/ApiGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/ApiInternalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/ApiProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Napp\Core\Api\Controllers;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;

/**
* Class ApiProxyController.
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/NappApiHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions src/Requests/ApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Router/Provider/RouterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -237,7 +237,7 @@ private function transformHeadersToServerVariables($headers)
$server = [];

foreach ($headers as $headerType => $headerValue) {
$headerType = 'HTTP_'.$headerType;
$headerType = 'HTTP_' . $headerType;

$server[$headerType] = $headerValue;
}
Expand Down
16 changes: 8 additions & 8 deletions src/Transformers/ApiTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Transformers/NoneTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/ValidateTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down