Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Contracts/FeatureConsumptionContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace LucasDotVin\Soulbscription\Contracts;

/**
* @mixin \Illuminate\Database\Eloquent\Model
*/
interface FeatureConsumptionContract
{
//
}
11 changes: 11 additions & 0 deletions src/Contracts/FeatureContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace LucasDotVin\Soulbscription\Contracts;

/**
* @mixin \Illuminate\Database\Eloquent\Model
*/
interface FeatureContract
{
//
}
11 changes: 11 additions & 0 deletions src/Contracts/FeatureTicketContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace LucasDotVin\Soulbscription\Contracts;

/**
* @mixin \Illuminate\Database\Eloquent\Model
*/
interface FeatureTicketContract
{
//
}
15 changes: 15 additions & 0 deletions src/Contracts/PlanContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace LucasDotVin\Soulbscription\Contracts;

use Illuminate\Support\Carbon;

/**
* @mixin \Illuminate\Database\Eloquent\Model
*/
interface PlanContract
{
public function calculateNextRecurrenceEnd(Carbon|string $start = null): Carbon;

public function calculateGraceDaysEnd(Carbon $recurrenceEnd): Carbon;
}
11 changes: 11 additions & 0 deletions src/Contracts/SubscriptionContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace LucasDotVin\Soulbscription\Contracts;

/**
* @mixin \Illuminate\Database\Eloquent\Model
*/
interface SubscriptionContract
{
//
}
11 changes: 11 additions & 0 deletions src/Contracts/SubscriptionRenewalContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace LucasDotVin\Soulbscription\Contracts;

/**
* @mixin \Illuminate\Database\Eloquent\Model
*/
interface SubscriptionRenewalContract
{
//
}
2 changes: 1 addition & 1 deletion src/Enums/PeriodicityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function getDateDifference(Carbon $from, Carbon $to, string $unit)
$delta = 1;
}

$unitInPlural = Str::plural($unit);
$unitInPlural = Str::plural(Str::studly(Str::lower($unit)));

$differenceMethodName = 'diffIn' . $unitInPlural;
$difference = abs($from->{$differenceMethodName}($to));
Expand Down
8 changes: 4 additions & 4 deletions src/Events/FeatureConsumed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use LucasDotVin\Soulbscription\Models\Feature;
use LucasDotVin\Soulbscription\Models\FeatureConsumption;
use LucasDotVin\Soulbscription\Contracts\FeatureConsumptionContract;
use LucasDotVin\Soulbscription\Contracts\FeatureContract;

class FeatureConsumed
{
Expand All @@ -16,8 +16,8 @@ class FeatureConsumed

public function __construct(
public $subscriber,
public Feature $feature,
public FeatureConsumption $featureConsumption,
public FeatureContract $feature,
public FeatureConsumptionContract $featureConsumption,
) {
//
}
Expand Down
8 changes: 4 additions & 4 deletions src/Events/FeatureTicketCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use LucasDotVin\Soulbscription\Models\Feature;
use LucasDotVin\Soulbscription\Models\FeatureTicket;
use LucasDotVin\Soulbscription\Contracts\FeatureContract;
use LucasDotVin\Soulbscription\Contracts\FeatureTicketContract;

class FeatureTicketCreated
{
Expand All @@ -16,8 +16,8 @@ class FeatureTicketCreated

public function __construct(
public $subscriber,
public Feature $feature,
public FeatureTicket $featureTicket,
public FeatureContract $feature,
public FeatureTicketContract $featureTicket,
) {
//
}
Expand Down
4 changes: 2 additions & 2 deletions src/Events/SubscriptionCanceled.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use LucasDotVin\Soulbscription\Models\Subscription;
use LucasDotVin\Soulbscription\Contracts\SubscriptionContract;

class SubscriptionCanceled
{
Expand All @@ -14,7 +14,7 @@ class SubscriptionCanceled
use SerializesModels;

public function __construct(
public Subscription $subscription,
public SubscriptionContract $subscription,
) {
//
}
Expand Down
4 changes: 2 additions & 2 deletions src/Events/SubscriptionRenewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use LucasDotVin\Soulbscription\Models\Subscription;
use LucasDotVin\Soulbscription\Contracts\SubscriptionContract;

class SubscriptionRenewed
{
Expand All @@ -14,7 +14,7 @@ class SubscriptionRenewed
use SerializesModels;

public function __construct(
public Subscription $subscription,
public SubscriptionContract $subscription,
) {
//
}
Expand Down
4 changes: 2 additions & 2 deletions src/Events/SubscriptionScheduled.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use LucasDotVin\Soulbscription\Models\Subscription;
use LucasDotVin\Soulbscription\Contracts\SubscriptionContract;

class SubscriptionScheduled
{
Expand All @@ -14,7 +14,7 @@ class SubscriptionScheduled
use SerializesModels;

public function __construct(
public Subscription $subscription,
public SubscriptionContract $subscription,
) {
//
}
Expand Down
4 changes: 2 additions & 2 deletions src/Events/SubscriptionStarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use LucasDotVin\Soulbscription\Models\Subscription;
use LucasDotVin\Soulbscription\Contracts\SubscriptionContract;

class SubscriptionStarted
{
Expand All @@ -14,7 +14,7 @@ class SubscriptionStarted
use SerializesModels;

public function __construct(
public Subscription $subscription,
public SubscriptionContract $subscription,
) {
//
}
Expand Down
4 changes: 2 additions & 2 deletions src/Events/SubscriptionSuppressed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use LucasDotVin\Soulbscription\Models\Subscription;
use LucasDotVin\Soulbscription\Contracts\SubscriptionContract;

class SubscriptionSuppressed
{
Expand All @@ -14,7 +14,7 @@ class SubscriptionSuppressed
use SerializesModels;

public function __construct(
public Subscription $subscription,
public SubscriptionContract $subscription,
) {
//
}
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Concerns/Expires.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public function initializeExpires()
}
}

public function expired()
public function expired(): bool
{
return $this->expired_at->isPast();
}

public function notExpired()
public function notExpired(): bool
{
return ! $this->expired();
}
Expand Down
6 changes: 5 additions & 1 deletion src/Models/Concerns/HandlesRecurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

use Illuminate\Support\Carbon;
use LucasDotVin\Soulbscription\Enums\PeriodicityType;
use Illuminate\Support\Str;

/**
* @property \LucasDotVin\Soulbscription\Enums\PeriodicityType $periodicity_type
*/
trait HandlesRecurrence
{
public function calculateNextRecurrenceEnd(Carbon|string $start = null): Carbon
Expand All @@ -22,7 +26,7 @@ public function calculateNextRecurrenceEnd(Carbon|string $start = null): Carbon
0,
);

$expirationDate = $start->copy()->add($this->periodicity_type, $this->periodicity + $recurrences);
$expirationDate = $start->copy()->add(Str::lower($this->periodicity_type), $this->periodicity + $recurrences);

return $expirationDate;
}
Expand Down
Loading