diff --git a/src/Contracts/Parser.php b/src/Contracts/Parser.php index e0cbe5b..5b75f2d 100644 --- a/src/Contracts/Parser.php +++ b/src/Contracts/Parser.php @@ -97,8 +97,6 @@ protected function getSortValue(): array return is_array($sort) ? $sort : explode(',', $sort); } - - /** * parses our filter parameters. */ diff --git a/src/Contracts/Relationships.php b/src/Contracts/Relationships.php index 0c63a9e..abe1246 100644 --- a/src/Contracts/Relationships.php +++ b/src/Contracts/Relationships.php @@ -2,14 +2,13 @@ namespace Phpsa\LaravelApiController\Contracts; -use Phpsa\LaravelApiController\Exceptions\ApiException; use Illuminate\Support\Str; +use Phpsa\LaravelApiController\Exceptions\ApiException; trait Relationships { - /** - * Gets whitelisted methods + * Gets whitelisted methods. * * @return array */ @@ -19,7 +18,7 @@ protected function getIncludesWhitelist(): array } /** - * Gets blacklisted methods + * Gets blacklisted methods. * * @return array */ @@ -29,7 +28,7 @@ protected function getIncludesBlacklist(): array } /** - * is method blacklisted + * is method blacklisted. * * @param string $item * @@ -49,7 +48,7 @@ public function isBlacklisted($item) */ protected function filterAllowedIncludes(array $includes): array { - return array_filter($includes, function ($item) { + return array_filter($includes, function ($item) { $callable = method_exists(self::$model, $item); if (! $callable) { @@ -65,7 +64,7 @@ protected function filterAllowedIncludes(array $includes): array return false; } - return empty($this->getIncludesWhitelist()) && ! Str::startsWith($item, '_');; + return empty($this->getIncludesWhitelist()) && ! Str::startsWith($item, '_'); }); } @@ -81,19 +80,19 @@ protected function storeRelated($item, $relateds, $data): void $relation = $item->$with(); $type = class_basename(get_class($relation)); - if(!in_array($type, ['HasOne','HasMany'])){ + if (! in_array($type, ['HasOne', 'HasMany'])) { throw new ApiException("$type mapping not implemented yet"); } - $collection = $type === 'HasOne' ? [$data [$with]]: $data[$with]; + $collection = $type === 'HasOne' ? [$data [$with]] : $data[$with]; $this->repository->with($with); $localKey = $relation->getLocalKeyName(); - foreach($collection as $relatedRecord){ - if(isset($relatedRecord[$localKey])){ + foreach ($collection as $relatedRecord) { + if (isset($relatedRecord[$localKey])) { $existanceCheck = [$localKey => $relatedRecord[$localKey]]; $item->$with()->updateOrCreate($existanceCheck, $relatedRecord); - }else{ + } else { $item->$with()->create($relatedRecord); } } diff --git a/src/Contracts/Validation.php b/src/Contracts/Validation.php index 357a7a7..18ef12d 100644 --- a/src/Contracts/Validation.php +++ b/src/Contracts/Validation.php @@ -7,7 +7,6 @@ trait Validation { - /** * \Illuminate\Http\Request instance. * diff --git a/src/Generator/ApiMakeCommand.php b/src/Generator/ApiMakeCommand.php index a3d9538..6d973d7 100644 --- a/src/Generator/ApiMakeCommand.php +++ b/src/Generator/ApiMakeCommand.php @@ -106,11 +106,10 @@ protected function createOptionals() { //dd($this->stubVariables); if ($this->option('model') || $this->option('all')) { - $params = ['name' => $this->stubVariables['model']['fullName']]; - if ($this->confirm('Would you like to create a Migration for this resource?') ){ + if ($this->confirm('Would you like to create a Migration for this resource?')) { $params['--migration'] = true; - if($this->confirm('Would you like to create a Seeder for this resource?')){ + if ($this->confirm('Would you like to create a Seeder for this resource?')) { $seederName = $this->stubVariables['model']['fullNameWithoutRoot'].'Seeder'; $this->call('make:seeder', ['name' => $seederName]); $this->line('Please add the following to your DatabaseSeeder.php file', 'important'); diff --git a/src/Helpers.php b/src/Helpers.php index 34d1caf..36eb801 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -1,26 +1,25 @@ qualifyUpdateQuery($data); - $columns = $this->getTableColumns(); $updates = array_intersect_key($data, array_flip($columns)); @@ -268,7 +267,6 @@ public function handleUpdateAction($id, $request) return $this->errorWrongArgs($exception->getMessage()); } - } /** diff --git a/src/Http/Middleware/SnakeCaseInputs.php b/src/Http/Middleware/SnakeCaseInputs.php index c2a7cd9..3125053 100644 --- a/src/Http/Middleware/SnakeCaseInputs.php +++ b/src/Http/Middleware/SnakeCaseInputs.php @@ -44,7 +44,7 @@ public function handle($request, Closure $next) $this->processParamBag($request->request); if ($request->isJson()) { - $this->processParamBag(/** @scrutinizer ignore-type */$request->json()); + $this->processParamBag(/* @scrutinizer ignore-type */$request->json()); } } diff --git a/src/Http/Resources/Contracts/CaseFormat.php b/src/Http/Resources/Contracts/CaseFormat.php index 7296db4..9826a57 100644 --- a/src/Http/Resources/Contracts/CaseFormat.php +++ b/src/Http/Resources/Contracts/CaseFormat.php @@ -1,28 +1,28 @@ caseFormat($request, $data); } protected function caseFormat($request, $data) { - switch(strtolower($request->header('X-Accept-Case-Type'))) - { - case "camel": - case "camel-case": + switch (strtolower($request->header('X-Accept-Case-Type'))) { + case 'camel': + case 'camel-case': return Helpers::camelCaseArrayKeys($data); break; - case "snake": - case "snake-case": + case 'snake': + case 'snake-case': return Helpers::snakeCaseArrayKeys($data); break; @@ -31,8 +31,4 @@ protected function caseFormat($request, $data) return $data; } - - } - -?> \ No newline at end of file