示例#1
0
 /**
  * {@inheritDoc}
  *
  * @throws InvalidArgumentException
  */
 public function __construct(AdapterInterface $adapter, array $config)
 {
     parent::__construct($adapter, $config);
     $missing = array();
     $required = array('user', 'password', 'serviceid');
     foreach ($required as $key) {
         if (empty($this->config[$key])) {
             $missing[] = $key;
         }
     }
     if (count($missing)) {
         throw new \InvalidArgumentException('The following config arguments cannot be empty: ' . implode(', ', $missing) . '.');
     }
 }
示例#2
0
 /**
  * {@inheritDoc}
  *
  * @throws MaxMessagesReachedException
  * @throws InvalidArgumentException
  */
 public function addMessage($to, $message, array $options = array(), $autoSend = false)
 {
     if (count($this->messages) == self::BATCH_MAX_QUANTITY) {
         throw new MaxMessagesReachedException('Unwire batch mode does not allow more than ' . self::BATCH_MAX_QUANTITY . ' pr. batch.');
     }
     if ($this->config['get_smsc']) {
         $options['smsc'] = $this->getSmsc($to);
     }
     if (isset($options['price']) && !preg_match('/[0-9]+\\.[0-9]{2}[A-Z]{3}/', $options['price'])) {
         throw new InvalidArgumentException('The price must be in the format "00.00XXX" where XXX is the correct currency code for the destination country.');
     }
     return parent::addMessage($to, $message, $options, $autoSend);
 }