Skip to content

Commit a4927c0

Browse files
authored
fix: fix empty array error (#9)
* fix: fix empty array error * Fix styling
1 parent 2040f50 commit a4927c0

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/Filament/Pages/ListBetterEmails.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ protected function getHeaderWidgets(): array
123123
];
124124
}
125125

126-
private static function formatMailState(array $emails, bool $mailOnly = false): string
126+
private static function formatMailState(?array $emails, bool $mailOnly = false): string
127127
{
128-
return collect($emails)
128+
return collect($emails ?? [])
129129
->mapWithKeys(fn ($value, $key) => [$key => $value ?? $key])
130130
->map(fn ($value, $key): string|int => $mailOnly ? $value : ($value == null ? $key : ($value !== $key ? sprintf('%s <%s>', $value, $key) : $key)))
131131
->implode(', ');

src/Filament/Schemas/BetterEmailInfolist.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ public static function buildMailEventsTab(): Tab
271271
]);
272272
}
273273

274-
private static function formatMailState(array $emails, bool $mailOnly = false): string
274+
private static function formatMailState(?array $emails, bool $mailOnly = false): string
275275
{
276-
return collect($emails)
276+
return collect($emails ?? [])
277277
->mapWithKeys(fn ($value, $key) => [$key => $value ?? $key])
278278
->map(fn ($value, $key): string|int => $mailOnly ? $key : ($value == null ? $key : ($value !== $key ? sprintf('%s <%s>', $value, $key) : $key)))
279279
->implode(', ');

src/Filament/Widgets/BetterEmailStatsWidget.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@ protected function getStats(): array
5050

5151
$widgets[] = Stat::make(__('Delivered'), number_format(($deliveredMails / $mailCount) * 100, 1).'%')
5252
->label(__('Delivered'))
53-
->description($deliveredMails.' '.__('of').' '.$mailCount.' '.__('emails'))
53+
->description($deliveredMails.' '.(string) __('of').' '.$mailCount.' '.(string) __('emails'))
5454
->color('success')
5555
->url($generateUrl('delivered'));
5656

5757
$widgets[] = Stat::make(__('Opened'), number_format(($openedMails / $mailCount) * 100, 1).'%')
5858
->label(__('Opened'))
59-
->description($openedMails.' '.__('of').' '.$mailCount.' '.__('emails'))
59+
->description($openedMails.' '.(string) __('of').' '.$mailCount.' '.(string) __('emails'))
6060
->color('info')
6161
->url($generateUrl('opened'));
6262

6363
$widgets[] = Stat::make(__('Clicked'), number_format(($clickedMails / $mailCount) * 100, 1).'%')
6464
->label(__('Clicked'))
65-
->description($clickedMails.' '.__('of').' '.$mailCount.' '.__('emails'))
65+
->description($clickedMails.' '.(string) __('of').' '.$mailCount.' '.(string) __('emails'))
6666
->color('clicked')
6767
->url($generateUrl('clicked'));
6868

6969
$widgets[] = Stat::make(__('Bounced'), number_format(($bouncedMails / $mailCount) * 100, 1).'%')
7070
->label(__('Bounced'))
71-
->description($bouncedMails.' '.__('of').' '.$mailCount.' '.__('emails'))
71+
->description($bouncedMails.' '.(string) __('of').' '.$mailCount.' '.(string) __('emails'))
7272
->color('danger')
7373
->url($generateUrl('bounced'));
7474

0 commit comments

Comments
 (0)