logger->info('SMS Notification'); if (!$user->canBeNotifiedBySms()) { $this->logger->warning('User cannot be notified by SMS'); return null; } $phoneNumber = $user->getPhoneNumber(); Assert::notEmpty($phoneNumber); Assert::notEmpty($subject); // fail silently, it should not happen as the number is validated in the form. // We want to avoid a 500 error from the vendors if (!u($phoneNumber)->startsWith('+')) { $this->logger->warning('Invalid phone number: '.$phoneNumber); return null; } try { return $this->texter->send(new SmsMessage( phone: $phoneNumber, subject: $subject )); } catch (\Exception $e) { // OK, the sms cannot be delivered, but this is not critical as the an // email is always sent $this->logger->warning('Cannot deliver text message: '.$e->getMessage()); return null; } $this->logger->info('SMS Sent Successfully'); } }