Skip to content

Commit

Permalink
Merge pull request #60 from clarkeash/feature/unlimited
Browse files Browse the repository at this point in the history
add easy unlimited option
  • Loading branch information
clarkeash committed Jun 5, 2020
2 parents 887a74b + b11b200 commit c373bc5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ Make an invite with 10 redemptions and no expiry.
Doorman::generate()->uses(10)->make();
```

Make an invite with unlimited redemptions and no expiry.
```php
Doorman::generate()->unlimited()->make();
```

Make an invite that expires on a specific date.
```php
$date = Carbon::now('UTC')->addDays(7);
Expand Down
13 changes: 11 additions & 2 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Clarkeash\Doorman;

use Carbon\Carbon;
use DateTimeInterface;
use Clarkeash\Doorman\Exceptions\DuplicateException;
use Clarkeash\Doorman\Models\BaseInvite;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -54,6 +55,14 @@ public function uses(int $amount = 1)
return $this;
}

/**
* @return $this
*/
public function unlimited()
{
return $this->uses(0);
}

/**
* @param string $email
*
Expand All @@ -72,11 +81,11 @@ public function for(string $email)
}

/**
* @param \DateTimeInterface $date
* @param DateTimeInterface $date
*
* @return $this
*/
public function expiresOn(\DateTimeInterface $date)
public function expiresOn(DateTimeInterface $date)
{
$this->expiry = $date;

Expand Down
10 changes: 10 additions & 0 deletions tests/Feature/GenerateInvitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,14 @@ public function it_will_generate_an_invite_only_once()

Assert::assertInstanceOf(Invite::class, $invite);
}

/**
* @test
*/
public function it_will_generate_an_invite_with_unlimited_redemptions()
{
$invite = Doorman::generate()->unlimited()->once();

Assert::assertEquals(0, $invite->uses);
}
}

0 comments on commit c373bc5

Please sign in to comment.