<?php
namespace App\SMS\EventListener;
use App\SMS\Event\SmsEvent;
use Psr\Log\LoggerInterface;
class SmsLogListener
{
public function __construct(private readonly LoggerInterface $logger)
{
}
/**
* Called after a "message" is sent.
*/
public function onSentSms(SmsEvent $event): void
{
$data = $event->getData();
$log = sprintf(
'Credit cost: %s | (%d) Success: %s | (%d) Failed: %s',
$data['totalCreditsRemoved'],
count($data['validReceivers']),
implode(', ', $data['validReceivers']),
count($data['invalidReceivers']),
implode(', ', $data['invalidReceivers'])
);
$this->logger->info($log);
}
}