src/Sms.php
public function send($numbers, $message, $type = self::TYPE_DEFAULT_MESSAGE)
    {
        if (!in_array($type, $this->allowedTypes())) {
            throw new NotSupportedException("Message type \"$type\" doesn't support.");
        }

        if (empty($numbers) || (is_array($numbers) && count($numbers) === 0) || empty($message)) {
            throw new \InvalidArgumentException('For sending sms, please, set phone number and message');
        }

        $response = $this->_client->sendMessage([
            'phones' => $numbers,
            'message' => $message,
            'id' => $this->smsIdGenerator(),
        ]);

        if ($this->_logger instanceof LoggerInterface) {
            if (is_array($numbers)) {
                foreach ($numbers as $number) {
                    $this->_logger->setRecord([
                        'sms_id' => isset($response['id']) ? $response['id'] : '',
                        'phone' => $number,
                        'message' => $message,
                        'error' => isset($response['error']) ? $response['error'] : 0,
                    ]);
                }
            } else {
                $this->_logger->setRecord([
                    'sms_id' => isset($response['id']) ? $response['id'] : '',
                    'phone' => $numbers,
                    'message' => $message,
                    'error' => isset($response['error']) ? $response['error'] : 0,
                ]);
            }
        }

        return isset($response['id']) ? $response['id'] : false;
    }
public function send($numbers, $message, $type = self::TYPE_DEFAULT_MESSAGE)
    {
        if (!in_array($type, $this->allowedTypes())) {
            throw new NotSupportedException("Message type \"$type\" doesn't support.");
        }

        if (empty($numbers) || (is_array($numbers) && count($numbers) === 0) || empty($message)) {
            throw new \InvalidArgumentException('For sending sms, please, set phone number and message');
        }

        $response = $this->_client->sendMessage([
            'phones' => $numbers,
            'message' => $message,
            'id' => $this->smsIdGenerator(),
        ]);

        if ($this->_logger instanceof LoggerInterface) {
            if (is_array($numbers)) {
                foreach ($numbers as $number) {
                    $this->_logger->setRecord([
                        'sms_id' => isset($response['id']) ? $response['id'] : '',
                        'phone' => $number,
                        'message' => $message,
                        'error' => isset($response['error']) ? $response['error'] : 0,
                    ]);
                }
            } else {
                $this->_logger->setRecord([
                    'sms_id' => isset($response['id']) ? $response['id'] : '',
                    'phone' => $numbers,
                    'message' => $message,
                    'error' => isset($response['error']) ? $response['error'] : 0,
                ]);
            }
        }

        return isset($response['id']) ? $response['id'] : false;
    }
public function send ( $ numbers , $ message , $ type = self :: TYPE_DEFAULT_MESSAGE ) { if ( ! in_array ( $ type , $ this -> allowedTypes ( ) ) ) { throw new NotSupportedException ( "Message type \"$type\" doesn't support." ) ; } if ( empty ( $ numbers ) || ( is_array ( $ numbers ) && count ( $ numbers ) === 0 ) || empty ( $ message ) ) { throw new \ InvalidArgumentException ( 'For sending sms, please, set phone number and message' ) ; } $ response = $ this -> _client -> sendMessage ( [ 'phones' => $ numbers , 'message' => $ message , 'id' => $ this -> smsIdGenerator ( ) , ] ) ; if ( $ this -> _logger instanceof LoggerInterface ) { if ( is_array ( $ numbers ) ) { foreach ( $ numbers as $ number ) { $ this -> _logger -> setRecord ( [ 'sms_id' => isset ( $ response [ 'id' ] ) ? $ response [ 'id' ] : '' , 'phone' => $ number , 'message' => $ message , 'error' => isset ( $ response [ 'error' ] ) ? $ response [ 'error' ] : 0 , ] ) ; } } else { $ this -> _logger -> setRecord ( [ 'sms_id' => isset ( $ response [ 'id' ] ) ? $ response [ 'id' ] : '' , 'phone' => $ numbers , 'message' => $ message , 'error' => isset ( $ response [ 'error' ] ) ? $ response [ 'error' ] : 0 , ] ) ; } } return isset ( $ response [ 'id' ] ) ? $ response [ 'id' ] : false ; }
Send sms message

@param string|array $numbers
@param string $message
@param int $type
@return bool|string
@throws NotSupportedException|\InvalidArgumentException
Send sms message