> $recipients * @param array> $excluded */ public function __construct( public array $recipients, public array $excluded, public int $selectedContactCount, public int $selectedGroupCount, ) {} /** * @return array */ public function summary(): array { return [ 'selected_contacts' => $this->selectedContactCount, 'selected_groups' => $this->selectedGroupCount, 'ready_numbers' => count($this->recipients), 'excluded_total' => count($this->excluded), 'opt_out' => $this->countExcludedReason('opt_out'), 'missing_phone' => $this->countExcludedReason('missing_phone'), 'invalid' => $this->countExcludedReason('invalid'), 'non_mobile' => $this->countExcludedReason('non_mobile'), 'duplicate' => $this->countExcludedReason('duplicate'), ]; } /** * @return array> */ public function excludedByReason(string $reason): array { return array_values(array_filter( $this->excluded, fn (array $entry): bool => ($entry['reason'] ?? null) === $reason, )); } private function countExcludedReason(string $reason): int { return count($this->excludedByReason($reason)); } }