Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
30 / 30
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CurrentSubscriptionDTO
100.00% covered (success)
100.00%
30 / 30
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\DTO;
4
5/**
6 * Data Transfer Object for current subscription response.
7 *
8 * Encapsulates all data needed for the current subscription endpoint response,
9 * providing type safety and structure for the response data.
10 *
11 * @property string $id The plan ID
12 * @property string $title The plan title
13 * @property string $identifier The plan identifier
14 * @property string|null $stripe_id The Stripe price ID
15 * @property mixed $created_at When the plan was created
16 * @property mixed $updated_at When the plan was last updated
17 * @property string $currency The currency code (e.g., 'usd')
18 * @property string $interval The billing interval (e.g., 'month', 'year')
19 * @property int|string $unit_amount The unit amount in cents
20 * @property array|null $flycuts_features The flycuts features
21 * @property array<string, int|string> $statistics User statistics for the plan
22 * @property array|null $referrals User referral information
23 * @property string $referral_key The user's referral key
24 * @property bool $on_trial Whether the user is on trial
25 * @property string|null $plan_status The subscription status
26 * @property mixed $ends_at When the subscription ends
27 * @property bool $used_trial Whether the user has used their trial
28 * @property bool $already_used_pro_trial Whether the user has used any pro trial
29 * @property array<string, mixed> $user_details User details
30 * @property bool $has_fly_learning Whether FlyLearning is enabled
31 * @property int $user_custom_prompts Number of custom prompts available
32 * @property int $user_persona_available Number of personas available
33 * @property bool $can_disable_flygrammar Whether FlyGrammar can be disabled
34 * @property int $flycut_deployment Number of flycut deployments
35 * @property int $flygrammar_actions Number of FlyGrammar actions
36 * @property int $prompts_per_day Number of prompts per day
37 * @property int $regenerate_count Number of regenerations available
38 */
39class CurrentSubscriptionDTO
40{
41    /**
42     * @param  string  $id  The plan ID
43     * @param  string  $title  The plan title
44     * @param  string  $identifier  The plan identifier
45     * @param  string|null  $stripe_id  The Stripe price ID
46     * @param  mixed  $created_at  When the plan was created
47     * @param  mixed  $updated_at  When the plan was last updated
48     * @param  string  $currency  The currency code
49     * @param  string  $interval  The billing interval
50     * @param  int|string  $unit_amount  The unit amount in cents
51     * @param  array|null  $flycuts_features  The flycuts features
52     * @param  array<string, int|string>  $statistics  User statistics
53     * @param  array|null  $referrals  User referral information
54     * @param  string  $referral_key  The user's referral key
55     * @param  bool  $on_trial  Whether the user is on trial
56     * @param  string|null  $plan_status  The subscription status
57     * @param  mixed  $ends_at  When the subscription ends
58     * @param  bool  $used_trial  Whether the user has used their trial
59     * @param  bool  $already_used_pro_trial  Whether the user has used any pro trial
60     * @param  array<string, mixed>  $user_details  User details
61     * @param  bool  $has_fly_learning  Whether FlyLearning is enabled
62     * @param  int  $user_custom_prompts  Number of custom prompts available
63     * @param  int  $user_persona_available  Number of personas available
64     * @param  bool  $can_disable_flygrammar  Whether FlyGrammar can be disabled
65     * @param  int  $flycut_deployment  Number of flycut deployments
66     * @param  int  $flygrammar_actions  Number of FlyGrammar actions
67     * @param  int  $prompts_per_day  Number of prompts per day
68     * @param  int  $regenerate_count  Number of regenerations available
69     */
70    public function __construct(
71        public readonly string $id,
72        public readonly string $title,
73        public readonly string $identifier,
74        public readonly ?string $stripe_id,
75        public readonly mixed $created_at,
76        public readonly mixed $updated_at,
77        public readonly string $currency,
78        public readonly string $interval,
79        public readonly int|string $unit_amount,
80        public readonly ?array $flycuts_features,
81        public readonly array $statistics,
82        public readonly ?array $referrals,
83        public readonly string $referral_key,
84        public readonly bool $on_trial,
85        public readonly ?string $plan_status,
86        public readonly mixed $ends_at,
87        public readonly bool $used_trial,
88        public readonly bool $already_used_pro_trial,
89        public readonly array $user_details,
90        public readonly bool $has_fly_learning,
91        public readonly int $user_custom_prompts,
92        public readonly int $user_persona_available,
93        public readonly bool $can_disable_flygrammar,
94        public readonly int $flycut_deployment,
95        public readonly int $flygrammar_actions,
96        public readonly int $prompts_per_day,
97        public readonly int $regenerate_count
98    ) {}
99
100    /**
101     * Convert the DTO to an array.
102     *
103     * @return array<string, mixed>
104     */
105    public function toArray(): array
106    {
107        return [
108            'id' => $this->id,
109            'title' => $this->title,
110            'identifier' => $this->identifier,
111            'stripe_id' => $this->stripe_id,
112            'created_at' => $this->created_at,
113            'updated_at' => $this->updated_at,
114            'currency' => $this->currency,
115            'interval' => $this->interval,
116            'unit_amount' => $this->unit_amount,
117            'flycuts_features' => $this->flycuts_features,
118            'statistics' => $this->statistics,
119            'referrals' => $this->referrals,
120            'referral_key' => $this->referral_key,
121            'on_trial' => $this->on_trial,
122            'plan_status' => $this->plan_status,
123            'ends_at' => $this->ends_at,
124            'used_trial' => $this->used_trial,
125            'already_used_pro_trial' => $this->already_used_pro_trial,
126            'user_details' => $this->user_details,
127            'has_fly_learning' => $this->has_fly_learning,
128            'user_custom_prompts' => $this->user_custom_prompts,
129            'user_persona_available' => $this->user_persona_available,
130            'can_disable_flygrammar' => $this->can_disable_flygrammar,
131            'flycut_deployment' => $this->flycut_deployment,
132            'flygrammar_actions' => $this->flygrammar_actions,
133            'prompts_per_day' => $this->prompts_per_day,
134            'regenerate_count' => $this->regenerate_count,
135        ];
136    }
137}