Subscription
in package
Abonnement d'un utilisateur, éventuellement porté par une entreprise, à un plan tarifaire.
Un abonnement appartient à un utilisateur unique (User, obligatoire), rattaché à un
plan unique (Plan, obligatoire) et, en option, à une entreprise (Company) quand
la souscription est portée par un compte professionnel. status prend l'une des valeurs
ACTIVE, CANCELLED, EXPIRED ou PENDING (constantes STATUS_*), initialisée à
PENDING au constructeur ; billingCycle prend MONTHLY ou YEARLY (constantes
BILLING_*). isActive(), isCancelled() et isExpired() sont des champs dérivés calculés
à partir de status et, pour l'expiration, également de la comparaison de endDate à
l'instant présent. getRemainingDays() est calculé à partir de endDate (nombre de jours
restants, 0 si dépassée, null si endDate n'est pas renseignée). getFormattedAmount()
formate amount en francs guinéens (GNF). Les méthodes cancel() et activate() modifient
status (et cancelledAt/cancellationReason pour la première) ainsi que updatedAt, sans
effectuer elles-mêmes de persistance. stripeSubscriptionId n'est renseigné que pour les
abonnements facturés via Stripe.
Attributes
- #[Entity]
- $repositoryClass: \App\Repository\SubscriptionRepository::class
Table of Contents
Constants
- BILLING_MONTHLY : mixed = 'MONTHLY'
- BILLING_YEARLY : mixed = 'YEARLY'
- STATUS_ACTIVE : mixed = 'ACTIVE'
- STATUS_CANCELLED : mixed = 'CANCELLED'
- STATUS_EXPIRED : mixed = 'EXPIRED'
- STATUS_PENDING : mixed = 'PENDING'
Properties
- $amount : string|null
- $autoRenew : bool|null
- $billingCycle : string|null
- $cancellationReason : string|null
- $cancelledAt : DateTimeImmutable|null
- $company : Company|null
- $createdAt : DateTimeImmutable|null
- $endDate : DateTimeImmutable|null
- $id : int|null
- $nextBillingDate : DateTimeImmutable|null
- $plan : Plan|null
- $startDate : DateTimeImmutable|null
- $status : string|null
- $stripeSubscriptionId : string|null
- $updatedAt : DateTimeImmutable|null
- $user : User|null
Methods
- __construct() : mixed
- activate() : static
- cancel() : static
- getAmount() : string|null
- getBillingCycle() : string|null
- getCancellationReason() : string|null
- getCancelledAt() : DateTimeImmutable|null
- getCompany() : Company|null
- getCreatedAt() : DateTimeImmutable|null
- getEndDate() : DateTimeImmutable|null
- getFormattedAmount() : string
- getId() : int|null
- getNextBillingDate() : DateTimeImmutable|null
- getPlan() : Plan|null
- getRemainingDays() : int|null
- getStartDate() : DateTimeImmutable|null
- getStatus() : string|null
- getStripeSubscriptionId() : string|null
- getUpdatedAt() : DateTimeImmutable|null
- getUser() : User|null
- isActive() : bool
- isAutoRenew() : bool|null
- isCancelled() : bool
- isExpired() : bool
- setAmount() : static
- setAutoRenew() : static
- setBillingCycle() : static
- setCancellationReason() : static
- setCancelledAt() : static
- setCompany() : static
- setCreatedAt() : static
- setEndDate() : static
- setNextBillingDate() : static
- setPlan() : static
- setStartDate() : static
- setStatus() : static
- setStripeSubscriptionId() : static
- setUpdatedAt() : static
- setUser() : static
Constants
BILLING_MONTHLY
public
mixed
BILLING_MONTHLY
= 'MONTHLY'
BILLING_YEARLY
public
mixed
BILLING_YEARLY
= 'YEARLY'
STATUS_ACTIVE
public
mixed
STATUS_ACTIVE
= 'ACTIVE'
STATUS_CANCELLED
public
mixed
STATUS_CANCELLED
= 'CANCELLED'
STATUS_EXPIRED
public
mixed
STATUS_EXPIRED
= 'EXPIRED'
STATUS_PENDING
public
mixed
STATUS_PENDING
= 'PENDING'
Properties
$amount
private
string|null
$amount
= null
Attributes
- #[Column]
- $type: \Doctrine\DBAL\Types\Types::DECIMAL
- $precision: 10
- $scale: 2
$autoRenew
private
bool|null
$autoRenew
= true
Attributes
- #[Column]
- $nullable: true
$billingCycle
private
string|null
$billingCycle
= null
Attributes
- #[Column]
- $length: 20
$cancellationReason
private
string|null
$cancellationReason
= null
Attributes
- #[Column]
- $length: 255
- $nullable: true
$cancelledAt
private
DateTimeImmutable|null
$cancelledAt
= null
Attributes
- #[Column]
- $nullable: true
$company
private
Company|null
$company
= null
Attributes
- #[JoinColumn]
- $nullable: true
- #[ManyToOne]
- $targetEntity: \App\Entity\Company::class
- $inversedBy: 'subscriptions'
$createdAt
private
DateTimeImmutable|null
$createdAt
= null
Attributes
- #[Column]
$endDate
private
DateTimeImmutable|null
$endDate
= null
Attributes
- #[Column]
- $nullable: true
$id
private
int|null
$id
= null
Attributes
- #[Column]
- #[GeneratedValue]
- #[Id]
$nextBillingDate
private
DateTimeImmutable|null
$nextBillingDate
= null
Attributes
- #[Column]
- $nullable: true
$plan
private
Plan|null
$plan
= null
Attributes
- #[JoinColumn]
- $nullable: false
- #[ManyToOne]
- $inversedBy: 'subscriptions'
$startDate
private
DateTimeImmutable|null
$startDate
= null
Attributes
- #[Column]
$status
private
string|null
$status
= null
Attributes
- #[Column]
- $length: 20
$stripeSubscriptionId
private
string|null
$stripeSubscriptionId
= null
Attributes
- #[Column]
- $length: 255
- $nullable: true
$updatedAt
private
DateTimeImmutable|null
$updatedAt
= null
Attributes
- #[Column]
$user
private
User|null
$user
= null
Attributes
- #[JoinColumn]
- $nullable: false
- #[ManyToOne]
- $inversedBy: 'subscriptions'
Methods
__construct()
public
__construct() : mixed
activate()
public
activate() : static
Return values
staticcancel()
public
cancel([string $reason = null ]) : static
Parameters
- $reason : string = null
Return values
staticgetAmount()
public
getAmount() : string|null
Return values
string|nullgetBillingCycle()
public
getBillingCycle() : string|null
Return values
string|nullgetCancellationReason()
public
getCancellationReason() : string|null
Return values
string|nullgetCancelledAt()
public
getCancelledAt() : DateTimeImmutable|null
Return values
DateTimeImmutable|nullgetCompany()
public
getCompany() : Company|null
Return values
Company|nullgetCreatedAt()
public
getCreatedAt() : DateTimeImmutable|null
Return values
DateTimeImmutable|nullgetEndDate()
public
getEndDate() : DateTimeImmutable|null
Return values
DateTimeImmutable|nullgetFormattedAmount()
public
getFormattedAmount() : string
Return values
stringgetId()
public
getId() : int|null
Return values
int|nullgetNextBillingDate()
public
getNextBillingDate() : DateTimeImmutable|null
Return values
DateTimeImmutable|nullgetPlan()
public
getPlan() : Plan|null
Return values
Plan|nullgetRemainingDays()
public
getRemainingDays() : int|null
Return values
int|nullgetStartDate()
public
getStartDate() : DateTimeImmutable|null
Return values
DateTimeImmutable|nullgetStatus()
public
getStatus() : string|null
Return values
string|nullgetStripeSubscriptionId()
public
getStripeSubscriptionId() : string|null
Return values
string|nullgetUpdatedAt()
public
getUpdatedAt() : DateTimeImmutable|null
Return values
DateTimeImmutable|nullgetUser()
public
getUser() : User|null
Return values
User|nullisActive()
public
isActive() : bool
Return values
boolisAutoRenew()
public
isAutoRenew() : bool|null
Return values
bool|nullisCancelled()
public
isCancelled() : bool
Return values
boolisExpired()
public
isExpired() : bool
Return values
boolsetAmount()
public
setAmount(string $amount) : static
Parameters
- $amount : string
Return values
staticsetAutoRenew()
public
setAutoRenew(bool|null $autoRenew) : static
Parameters
- $autoRenew : bool|null
Return values
staticsetBillingCycle()
public
setBillingCycle(string $billingCycle) : static
Parameters
- $billingCycle : string
Return values
staticsetCancellationReason()
public
setCancellationReason(string|null $cancellationReason) : static
Parameters
- $cancellationReason : string|null
Return values
staticsetCancelledAt()
public
setCancelledAt(DateTimeImmutable|null $cancelledAt) : static
Parameters
- $cancelledAt : DateTimeImmutable|null
Return values
staticsetCompany()
public
setCompany(Company|null $company) : static
Parameters
- $company : Company|null
Return values
staticsetCreatedAt()
public
setCreatedAt(DateTimeImmutable $createdAt) : static
Parameters
- $createdAt : DateTimeImmutable
Return values
staticsetEndDate()
public
setEndDate(DateTimeImmutable|null $endDate) : static
Parameters
- $endDate : DateTimeImmutable|null
Return values
staticsetNextBillingDate()
public
setNextBillingDate(DateTimeImmutable|null $nextBillingDate) : static
Parameters
- $nextBillingDate : DateTimeImmutable|null
Return values
staticsetPlan()
public
setPlan(Plan|null $plan) : static
Parameters
- $plan : Plan|null
Return values
staticsetStartDate()
public
setStartDate(DateTimeImmutable $startDate) : static
Parameters
- $startDate : DateTimeImmutable
Return values
staticsetStatus()
public
setStatus(string $status) : static
Parameters
- $status : string
Return values
staticsetStripeSubscriptionId()
public
setStripeSubscriptionId(string|null $stripeSubscriptionId) : static
Parameters
- $stripeSubscriptionId : string|null
Return values
staticsetUpdatedAt()
public
setUpdatedAt(DateTimeImmutable $updatedAt) : static
Parameters
- $updatedAt : DateTimeImmutable
Return values
staticsetUser()
public
setUser(User|null $user) : static
Parameters
- $user : User|null