Skip to content

Commit

Permalink
style: apply automated php-cs-fixer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi authored and github-actions[bot] committed Dec 31, 2024
1 parent 08bdcb1 commit 0cc10c0
Show file tree
Hide file tree
Showing 52 changed files with 323 additions and 342 deletions.
2 changes: 1 addition & 1 deletion src/Abstracts/Providers/AggregateServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class AggregateServiceProvider extends LaravelAggregateServiceProvider

final public function runRegister(): void
{
/** @var $instances */
/* @var $instances */
$this->instances = [];

foreach ($this->providers as $provider) {
Expand Down
2 changes: 2 additions & 0 deletions src/Loaders/Apiato.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ private function getRoutePathsForUI(string $containerPath, string $ui): string
private function getFilesSortedByName(string $apiRoutesPath): array
{
$files = File::allFiles($apiRoutesPath);

return Arr::sort($files, static fn ($file) => $file->getFilename());
}

Expand Down Expand Up @@ -166,6 +167,7 @@ private function getRouteFileVersionFromFileName(SplFileInfo $file): string|bool
$fileNameWithoutExtensionExploded = explode('.', $fileNameWithoutExtension);

end($fileNameWithoutExtensionExploded);

return prev($fileNameWithoutExtensionExploded);
}

Expand Down
6 changes: 4 additions & 2 deletions src/Providers/ApiatoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ public function runLoadersBoot(): void
protected function configureRateLimiting(): void
{
if (config('apiato.api.rate-limiter.enabled')) {
RateLimiter::for(config('apiato.api.rate-limiter.name'),
RateLimiter::for(
config('apiato.api.rate-limiter.name'),
static function (Request $request) {
return Limit::perMinutes(
config('apiato.api.rate-limiter.expires'),
config('apiato.api.rate-limiter.attempts'),
)->by($request->user()?->id ?: $request->ip());
});
},
);
}
}
}
7 changes: 3 additions & 4 deletions tests/Functional/Providers/ApiatoServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Apiato\Core\Providers\ApiatoServiceProvider;
use Apiato\Core\Providers\MacroProviders\CollectionMacroServiceProvider;
use Apiato\Core\Providers\MacroProviders\ConfigMacroServiceProvider;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Foundation\Http\Kernel;
use Pest\Expectation;
use Tests\Infrastructure\Dummies\AnotherSingletonClass;
Expand All @@ -19,7 +20,6 @@
use Tests\Infrastructure\Fakes\Providers\DeferredServiceProvider;
use Tests\Infrastructure\Fakes\Providers\FirstServiceProvider;
use Tests\Infrastructure\Fakes\Providers\SecondServiceProvider;
use Illuminate\Foundation\AliasLoader;

describe(class_basename(ApiatoServiceProvider::class), function (): void {
it('registers the providers that are listed in the $providers property', function (): void {
Expand All @@ -38,7 +38,6 @@
}
});


it('adds aliases from all registered providers', function (): void {
$aliases = [
'Foo' => FirstServiceProvider::class,
Expand All @@ -56,7 +55,7 @@
it('binds the bindings that are listed in the $bindings property', function (): void {
$bindings = [
UselessInterface::class => UselessClass::class,
AnotherUselessInterface::class => AnotherUselessClass::class
AnotherUselessInterface::class => AnotherUselessClass::class,
];

foreach ($bindings as $key => $value) {
Expand All @@ -69,7 +68,7 @@
it('binds the singletons that are listed in the $singletons property', function (): void {
$singletons = [
SingletonInterface::class => SingletonClass::class,
AnotherSingletonInterface::class => AnotherSingletonClass::class
AnotherSingletonInterface::class => AnotherSingletonClass::class,
];

foreach ($singletons as $key => $value) {
Expand Down
6 changes: 4 additions & 2 deletions tests/Functional/Providers/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@

it('can discover events from configured path', function (): void {
Event::fake()
->assertListening(BookCreated::class,
->assertListening(
BookCreated::class,
BookCreatedListener::class,
);
});

it('can manually register events', function (): void {
Event::fake()
->assertListening(BookCreated::class,
->assertListening(
BookCreated::class,
BookCreatedListener::class,
);
})->todo();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| MySection Section Book Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
return new class extends Migration {
public function up(): void
{
Schema::create('books', static function (Blueprint $table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Events;

use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Models\Book;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Parents\Events\Event as ParentEvent;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\PrivateChannel;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Models\Book;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Parents\Events\Event as ParentEvent;

class BookCreated extends ParentEvent
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Middlewares;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class BeforeMiddleware
{
public function handle(Request $request, Closure $next): Response
public function handle(Request $request, \Closure $next): Response
{
return $next($request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class EventServiceProvider extends ParentEventServiceProvider
{
protected $listen = [
// BookCreatedListener::class => [
// BookCreated::class,
// ],
// BookCreatedListener::class => [
// BookCreated::class,
// ],
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Tasks;

use Tests\Infrastructure\Fakes\Laravel\app\Ship\Exceptions\CreateResourceFailed;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Parents\Tasks\Task as ParentTask;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Data\Repositories\BookRepository;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Events\BookCreated;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Models\Book;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Exceptions\CreateResourceFailed;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Parents\Tasks\Task as ParentTask;

class CreateBookTask extends ParentTask
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Tasks;

use Tests\Infrastructure\Fakes\Laravel\app\Ship\Exceptions\ResourceNotFound;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Parents\Tasks\Task as ParentTask;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Data\Repositories\BookRepository;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Events\BookRequested;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Models\Book;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Exceptions\ResourceNotFound;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Parents\Tasks\Task as ParentTask;

class FindBookByIdTask extends ParentTask
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers;

use Illuminate\Http\JsonResponse;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Actions\CreateBookAction;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Requests\CreateBookRequest;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Transformers\BookTransformer;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Parents\Controllers\ApiController;
use Illuminate\Http\JsonResponse;

class CreateBookController extends ApiController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers;

use Illuminate\Http\JsonResponse;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Actions\DeleteBookAction;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Requests\DeleteBookRequest;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Parents\Controllers\ApiController;
use Illuminate\Http\JsonResponse;

class DeleteBookController extends ApiController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use Apiato\Core\Exceptions\CoreInternalErrorException;
use Apiato\Core\Exceptions\InvalidTransformerException;
use Prettus\Repository\Exceptions\RepositoryException;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\Actions\ListBooksAction;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Requests\ListBooksRequest;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Transformers\BookTransformer;
use Tests\Infrastructure\Fakes\Laravel\app\Ship\Parents\Controllers\ApiController;
use Prettus\Repository\Exceptions\RepositoryException;

class ListBooksController extends ApiController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

/**
* @apiGroup Book
*
* @apiName Invoke
*
* @api {POST} /v1/books Invoke
*
* @apiDescription Endpoint description here...
*
* @apiVersion 1.0.0
*
* @apiPermission Authenticated ['permissions' => '', 'roles' => '']
*
* @apiHeader {String} accept=application/json
Expand All @@ -22,9 +25,8 @@
* }
*/

use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\CreateBookController;
use Illuminate\Support\Facades\Route;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\CreateBookController;

Route::post('books', CreateBookController::class)
->middleware(['auth:api']);

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

/**
* @apiGroup Book
*
* @apiName Invoke
*
* @api {DELETE} /v1/books/:id Invoke
*
* @apiDescription Endpoint description here...
*
* @apiVersion 1.0.0
*
* @apiPermission Authenticated ['permissions' => '', 'roles' => '']
*
* @apiHeader {String} accept=application/json
Expand All @@ -22,9 +25,8 @@
* }
*/

use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\DeleteBookController;
use Illuminate\Support\Facades\Route;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\DeleteBookController;

Route::delete('books/{id}', DeleteBookController::class)
->middleware(['auth:api']);

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

/**
* @apiGroup Book
*
* @apiName Invoke
*
* @api {GET} /v1/books/:id Invoke
*
* @apiDescription Endpoint description here...
*
* @apiVersion 1.0.0
*
* @apiPermission Authenticated ['permissions' => '', 'roles' => '']
*
* @apiHeader {String} accept=application/json
Expand All @@ -22,9 +25,8 @@
* }
*/

use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\FindBookByIdController;
use Illuminate\Support\Facades\Route;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\FindBookByIdController;

Route::get('books/{id}', FindBookByIdController::class)
->middleware(['auth:api']);

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

/**
* @apiGroup Book
*
* @apiName Invoke
*
* @api {GET} /v1/books Invoke
*
* @apiDescription Endpoint description here...
*
* @apiVersion 1.0.0
*
* @apiPermission Authenticated ['permissions' => '', 'roles' => '']
*
* @apiHeader {String} accept=application/json
Expand All @@ -22,9 +25,8 @@
* }
*/

use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\ListBooksController;
use Illuminate\Support\Facades\Route;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\ListBooksController;

Route::get('books', ListBooksController::class)
->middleware(['auth:api']);

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

/**
* @apiGroup Book
*
* @apiName Invoke
*
* @api {PATCH} /v1/books/:id Invoke
*
* @apiDescription Endpoint description here...
*
* @apiVersion 1.0.0
*
* @apiPermission Authenticated ['permissions' => '', 'roles' => '']
*
* @apiHeader {String} accept=application/json
Expand All @@ -22,9 +25,8 @@
* }
*/

use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\UpdateBookController;
use Illuminate\Support\Facades\Route;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\API\Controllers\UpdateBookController;

Route::patch('books/{id}', UpdateBookController::class)
->middleware(['auth:api']);

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php

use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\WEB\Controllers\CreateBookController;
use Illuminate\Support\Facades\Route;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\WEB\Controllers\CreateBookController;

Route::get('books/create', [CreateBookController::class, 'create'])
->middleware(['auth:web']);

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php

use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\WEB\Controllers\DeleteBookController;
use Illuminate\Support\Facades\Route;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\WEB\Controllers\DeleteBookController;

Route::delete('books/{id}', [DeleteBookController::class, 'destroy'])
->middleware(['auth:web']);

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php

use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\WEB\Controllers\UpdateBookController;
use Illuminate\Support\Facades\Route;
use Tests\Infrastructure\Fakes\Laravel\app\Containers\MySection\Book\UI\WEB\Controllers\UpdateBookController;

Route::get('books/{id}/edit', [UpdateBookController::class, 'edit'])
->middleware(['auth:web']);

Loading

0 comments on commit 0cc10c0

Please sign in to comment.