@@ -52,12 +52,14 @@ protected function handleInteractive(): int
5252 $ title = $ this ->ask ('Notification title ' );
5353 if (empty ($ title )) {
5454 $ this ->error ('Title is required ' );
55+
5556 return self ::FAILURE ;
5657 }
5758
5859 $ message = $ this ->ask ('Notification message ' );
5960 if (empty ($ message )) {
6061 $ this ->error ('Message is required ' );
62+
6163 return self ::FAILURE ;
6264 }
6365
@@ -73,16 +75,17 @@ protected function handleInteractive(): int
7375 } elseif ($ target === 'user ' ) {
7476 $ userType = $ this ->choice ('Select user type ' , ['customer ' , 'admin ' ]);
7577 $ userId = $ this ->ask ('Enter user ID ' );
76- if (!is_numeric ($ userId )) {
78+ if (! is_numeric ($ userId )) {
7779 $ this ->error ('User ID must be numeric ' );
80+
7881 return self ::FAILURE ;
7982 }
8083 $ targetValue = $ userId ;
8184 }
8285
8386 $ actionUrl = $ this ->ask ('Action URL (optional) ' );
8487 $ imageUrl = $ this ->ask ('Image URL (optional) ' );
85-
88+
8689 $ addData = $ this ->confirm ('Add custom data? ' , false );
8790 $ data = null ;
8891 if ($ addData ) {
@@ -91,6 +94,7 @@ protected function handleInteractive(): int
9194 $ data = json_decode ($ dataInput , true );
9295 if (json_last_error () !== JSON_ERROR_NONE ) {
9396 $ this ->error ('Invalid JSON data ' );
97+
9498 return self ::FAILURE ;
9599 }
96100 }
@@ -99,8 +103,9 @@ protected function handleInteractive(): int
99103 $ schedule = null ;
100104 if ($ this ->confirm ('Schedule notification? ' , false )) {
101105 $ schedule = $ this ->ask ('Schedule time (Y-m-d H:i:s format) ' );
102- if ($ schedule && !strtotime ($ schedule )) {
106+ if ($ schedule && ! strtotime ($ schedule )) {
103107 $ this ->error ('Invalid date format ' );
108+
104109 return self ::FAILURE ;
105110 }
106111 }
@@ -131,6 +136,7 @@ protected function handleNonInteractive(): int
131136
132137 if (empty ($ title ) || empty ($ message )) {
133138 $ this ->error ('Title and message are required. Use --title and --message options or run with --interactive ' );
139+
134140 return self ::FAILURE ;
135141 }
136142
@@ -140,6 +146,7 @@ protected function handleNonInteractive(): int
140146 // Validate target and target-value combination
141147 if (in_array ($ target , ['platform ' , 'user_type ' , 'user ' ]) && empty ($ targetValue )) {
142148 $ this ->error ("Target value is required when target is ' {$ target }' " );
149+
143150 return self ::FAILURE ;
144151 }
145152
@@ -148,13 +155,15 @@ protected function handleNonInteractive(): int
148155 $ data = json_decode ($ this ->option ('data ' ), true );
149156 if (json_last_error () !== JSON_ERROR_NONE ) {
150157 $ this ->error ('Invalid JSON data ' );
158+
151159 return self ::FAILURE ;
152160 }
153161 }
154162
155163 $ schedule = $ this ->option ('schedule ' );
156- if ($ schedule && !strtotime ($ schedule )) {
164+ if ($ schedule && ! strtotime ($ schedule )) {
157165 $ this ->error ('Invalid schedule date format ' );
166+
158167 return self ::FAILURE ;
159168 }
160169
@@ -189,6 +198,7 @@ protected function sendNotification(array $notificationData): int
189198 if (isset ($ notificationData ['scheduled_at ' ]) && $ notificationData ['scheduled_at ' ]) {
190199 $ this ->info ("✅ Notification scheduled for: {$ notificationData ['scheduled_at ' ]}" );
191200 $ this ->info ("Notification ID: {$ pushNotification ->id }" );
201+
192202 return self ::SUCCESS ;
193203 }
194204
@@ -205,6 +215,7 @@ protected function sendNotification(array $notificationData): int
205215 'error ' => $ e ->getMessage (),
206216 'data ' => $ notificationData ,
207217 ]);
218+
208219 return self ::FAILURE ;
209220 }
210221 }
@@ -226,7 +237,8 @@ protected function sendBasedOnTarget(array $notificationData): array
226237
227238 case 'user ' :
228239 $ userType = $ notificationData ['user_type ' ] ?? 'customer ' ;
229- return $ this ->pushNotificationService ->sendToUser ($ userType , (int )$ targetValue , $ notificationData );
240+
241+ return $ this ->pushNotificationService ->sendToUser ($ userType , (int ) $ targetValue , $ notificationData );
230242
231243 default :
232244 throw new \InvalidArgumentException ("Invalid target type: {$ target }" );
@@ -236,7 +248,7 @@ protected function sendBasedOnTarget(array $notificationData): array
236248 protected function displayResult (array $ result , PushNotification $ pushNotification ): void
237249 {
238250 $ this ->line ('' );
239-
251+
240252 if ($ result ['success ' ]) {
241253 $ this ->info ('✅ Notification sent successfully! ' );
242254 } else {
0 commit comments