src/Octopush/Message.php
public function setParams(array $params = [])
    {
        if (empty($params) || count($params) < 4) {
            throw new \InvalidArgumentException(
            'Missing required params for Octopush message'
          );
        }

        foreach ($params as $key => $param) {
            if (!in_array($key, array_merge($this->requiredKeys, $this->optionalKeys))) {
                throw new \InvalidArgumentException(
                  'Missing required params for Octopush message'
                );
            }
        }

        foreach ($params as $key => $value) {
            $method = 'set' . $this->setMethod($key);
            $this->$method($value);
        }

        // set default params
        $this->params['sending_time'] = (new \DateTime())->getTimestamp();

        if (isset($this->params['sending_date'])) {
            $this->params['sms_mode'] = static::WITH_DELAY;
        }

        if (isset($this->params['request_keys'])) {
            $this->params['request_sha1'] = $this->encrypt($this->params);
        }

        if ($this->params['sms_type'] === 'FR') {
            $this->params['sms_text'] .= PHP_EOL . 'STOP au XXXXX';
        }

        return $this;
    }
public function setParams(array $params = [])
    {
        if (empty($params) || count($params) < 4) {
            throw new \InvalidArgumentException(
            'Missing required params for Octopush message'
          );
        }

        foreach ($params as $key => $param) {
            if (!in_array($key, array_merge($this->requiredKeys, $this->optionalKeys))) {
                throw new \InvalidArgumentException(
                  'Missing required params for Octopush message'
                );
            }
        }

        foreach ($params as $key => $value) {
            $method = 'set' . $this->setMethod($key);
            $this->$method($value);
        }

        // set default params
        $this->params['sending_time'] = (new \DateTime())->getTimestamp();

        if (isset($this->params['sending_date'])) {
            $this->params['sms_mode'] = static::WITH_DELAY;
        }

        if (isset($this->params['request_keys'])) {
            $this->params['request_sha1'] = $this->encrypt($this->params);
        }

        if ($this->params['sms_type'] === 'FR') {
            $this->params['sms_text'] .= PHP_EOL . 'STOP au XXXXX';
        }

        return $this;
    }
public function setParams ( array $ params = [ ] ) { if ( empty ( $ params ) || count ( $ params ) < 4 ) { throw new \ InvalidArgumentException ( 'Missing required params for Octopush message' ) ; } foreach ( $ params as $ key => $ param ) { if ( ! in_array ( $ key , array_merge ( $ this -> requiredKeys , $ this -> optionalKeys ) ) ) { throw new \ InvalidArgumentException ( 'Missing required params for Octopush message' ) ; } } foreach ( $ params as $ key => $ value ) { $ method = 'set' . $ this -> setMethod ( $ key ) ; $ this -> $ method ( $ value ) ; } // set default params $ this -> params [ 'sending_time' ] = ( new \ DateTime ( ) ) -> getTimestamp ( ) ; if ( isset ( $ this -> params [ 'sending_date' ] ) ) { $ this -> params [ 'sms_mode' ] = static :: WITH_DELAY ; } if ( isset ( $ this -> params [ 'request_keys' ] ) ) { $ this -> params [ 'request_sha1' ] = $ this -> encrypt ( $ this -> params ) ; } if ( $ this -> params [ 'sms_type' ] === 'FR' ) { $ this -> params [ 'sms_text' ] .= PHP_EOL . 'STOP au XXXXX' ; } return $ this ; }
Set the parameters message

@param array $params The parameters message required and optionnals
@return \Octopush\Message
@throws \InvalidArgumentException
Set the parameters message