From fef29f3e0d1bb2fc8030eb8ecce07f6170f9120d Mon Sep 17 00:00:00 2001 From: Mateus Junges Date: Sun, 28 Jan 2024 15:15:54 -0300 Subject: [PATCH] Rename InviteCodes to Factory. Rename interface --- ...iteCodesContract.php => InviteCodesFactory.php} | 14 +++++++------- src/Facades/InviteCodes.php | 6 +++--- src/{InviteCodes.php => Factory.php} | 4 ++-- src/InviteCodesServiceProvider.php | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) rename src/Contracts/{InviteCodesContract.php => InviteCodesFactory.php} (79%) rename src/{InviteCodes.php => Factory.php} (98%) diff --git a/src/Contracts/InviteCodesContract.php b/src/Contracts/InviteCodesFactory.php similarity index 79% rename from src/Contracts/InviteCodesContract.php rename to src/Contracts/InviteCodesFactory.php index e09b31b..1a48122 100644 --- a/src/Contracts/InviteCodesContract.php +++ b/src/Contracts/InviteCodesFactory.php @@ -10,13 +10,13 @@ use Junges\InviteCodes\Exceptions\InviteWithRestrictedUsageException; use Junges\InviteCodes\Exceptions\SoldOutException; use Junges\InviteCodes\Exceptions\UserLoggedOutException; -use Junges\InviteCodes\InviteCodes; +use Junges\InviteCodes\Factory; use Junges\InviteCodes\Models\Invite; -interface InviteCodesContract +interface InviteCodesFactory { /** If used, no events will be dispatched. */ - public function withoutEvents(): InviteCodes; + public function withoutEvents(): Factory; /** * @throws ExpiredInviteCodeException @@ -28,20 +28,20 @@ public function withoutEvents(): InviteCodes; public function redeem(string $code): Invite; /** Create a new invite */ - public function create(): InviteCodes; + public function create(): Factory; /** * Set the number of allowed redemptions. * * @throws InviteMustBeAbleToBeRedeemedException */ - public function maxUsages(int $usages = 1): InviteCodes; + public function maxUsages(int $usages = 1): Factory; /** Set the max usages amount to one. */ - public function canBeUsedOnce(): InviteCodes; + public function canBeUsedOnce(): Factory; /** Set the user who can use this invite. */ - public function restrictUsageTo(string $email): InviteCodes; + public function restrictUsageTo(string $email): Factory; /** Save the created invite.*/ public function save(): Invite; diff --git a/src/Facades/InviteCodes.php b/src/Facades/InviteCodes.php index 635057e..4ea1338 100644 --- a/src/Facades/InviteCodes.php +++ b/src/Facades/InviteCodes.php @@ -4,11 +4,11 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Facade; -use Junges\InviteCodes\Contracts\InviteCodesContract; +use Junges\InviteCodes\Contracts\InviteCodesFactory; use Junges\InviteCodes\Models\Invite; /** - * Class InviteCodes. + * Class Factory. * * @method static $this withoutEvents() Will dispatch no events. * @method static $this redeem(string $code) Redeem an invite code. @@ -25,6 +25,6 @@ class InviteCodes extends Facade { public static function getFacadeAccessor(): string { - return InviteCodesContract::class; + return InviteCodesFactory::class; } } diff --git a/src/InviteCodes.php b/src/Factory.php similarity index 98% rename from src/InviteCodes.php rename to src/Factory.php index 40f5676..3dfb6ad 100644 --- a/src/InviteCodes.php +++ b/src/Factory.php @@ -7,7 +7,7 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Str; -use Junges\InviteCodes\Contracts\InviteCodesContract; +use Junges\InviteCodes\Contracts\InviteCodesFactory; use Junges\InviteCodes\Contracts\InviteContract; use Junges\InviteCodes\Events\InviteRedeemedEvent; use Junges\InviteCodes\Exceptions\DuplicateInviteCodeException; @@ -21,7 +21,7 @@ use Junges\InviteCodes\Models\Invite; use Symfony\Component\HttpFoundation\Response; -class InviteCodes implements InviteCodesContract +class Factory implements InviteCodesFactory { protected int $max_usages; protected ?string $to = null; diff --git a/src/InviteCodesServiceProvider.php b/src/InviteCodesServiceProvider.php index 8a44cb0..1f68388 100644 --- a/src/InviteCodesServiceProvider.php +++ b/src/InviteCodesServiceProvider.php @@ -4,7 +4,7 @@ use Illuminate\Support\ServiceProvider; use Junges\InviteCodes\Console\Commands\DeleteExpiredInvitesCommand; -use Junges\InviteCodes\Contracts\InviteCodesContract; +use Junges\InviteCodes\Contracts\InviteCodesFactory; final class InviteCodesServiceProvider extends ServiceProvider { @@ -50,6 +50,6 @@ private function loadCommands(): void /** Register any application services. */ public function register(): void { - $this->app->bind(InviteCodesContract::class, InviteCodes::class); + $this->app->bind(InviteCodesFactory::class, Factory::class); } }