Skip to content

Commit

Permalink
Rename InviteCodes to Factory. Rename interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusjunges committed Jan 28, 2024
1 parent cef0e4f commit fef29f3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Facades/InviteCodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -25,6 +25,6 @@ class InviteCodes extends Facade
{
public static function getFacadeAccessor(): string
{
return InviteCodesContract::class;
return InviteCodesFactory::class;
}
}
4 changes: 2 additions & 2 deletions src/InviteCodes.php → src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/InviteCodesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
}

0 comments on commit fef29f3

Please sign in to comment.