public function send(Sms $sms): array
    {
        if (! $sms->hasRecipients()) {
            throw new NoRecipientsSpecifiedException();
        }

        $messages = [];

        $recipients = $sms->getRecipients();
        foreach (array_chunk($recipients, Recipients::MAX) as $chunk) {
            $message = clone $sms;
            $message
                ->setRecipients($chunk)
                ->clearRecipientVariables()
            ;

            foreach ($chunk as $recipient) {
                if (! isset($sms->getRecipientVariables()[$recipient])) {
                    continue;
                }

                foreach ($sms->getRecipientVariables()[$recipient] as $variable => $value) {
                    $message->addRecipientVariable($recipient, $variable, $value);
                }
            }

            $messages[] = $message;
        }

        $responses = [];
        foreach ($messages as $message) {
            $request = $this->prepareRequest($message);

            $responses[] = $this->executeRequest($request);
        }

        return $responses;
    }
public function send(Sms $sms): array
    {
        if (! $sms->hasRecipients()) {
            throw new NoRecipientsSpecifiedException();
        }

        $messages = [];

        $recipients = $sms->getRecipients();
        foreach (array_chunk($recipients, Recipients::MAX) as $chunk) {
            $message = clone $sms;
            $message
                ->setRecipients($chunk)
                ->clearRecipientVariables()
            ;

            foreach ($chunk as $recipient) {
                if (! isset($sms->getRecipientVariables()[$recipient])) {
                    continue;
                }

                foreach ($sms->getRecipientVariables()[$recipient] as $variable => $value) {
                    $message->addRecipientVariable($recipient, $variable, $value);
                }
            }

            $messages[] = $message;
        }

        $responses = [];
        foreach ($messages as $message) {
            $request = $this->prepareRequest($message);

            $responses[] = $this->executeRequest($request);
        }

        return $responses;
    }
public function send ( Sms $ sms ) : array { if ( ! $ sms -> hasRecipients ( ) ) { throw new NoRecipientsSpecifiedException ( ) ; } $ messages = [ ] ; $ recipients = $ sms -> getRecipients ( ) ; foreach ( array_chunk ( $ recipients , Recipients :: MAX ) as $ chunk ) { $ message = clone $ sms ; $ message -> setRecipients ( $ chunk ) -> clearRecipientVariables ( ) ; foreach ( $ chunk as $ recipient ) { if ( ! isset ( $ sms -> getRecipientVariables ( ) [ $ recipient ] ) ) { continue ; } foreach ( $ sms -> getRecipientVariables ( ) [ $ recipient ] as $ variable => $ value ) { $ message -> addRecipientVariable ( $ recipient , $ variable , $ value ) ; } } $ messages [ ] = $ message ; } $ responses = [ ] ; foreach ( $ messages as $ message ) { $ request = $ this -> prepareRequest ( $ message ) ; $ responses [ ] = $ this -> executeRequest ( $ request ) ; } return $ responses ; }
Sends an SMS.

@param Sms $sms

@return Response[]

@throws EmptyResponseException
@throws NoRecipientsSpecifiedException
@throws UnknownErrorResponseException
Sends an SMS .