public function setData(array $data)
    {
        $reservedDataKeys = array(
            'from',
            'notification',
            'to',
            'registration_ids',
            'collapse_key',
            'priority',
            'restricted_package_name',
            'content_available',
            'delay_while_idle',
            'dry_run',
            'time_to_live',
            'data',
        );

        foreach ($data as $key => $value) {

            if (!is_string($key)) {
                throw new \InvalidArgumentException('Data keys must be of type string in order to convert data in a valid JSON Object.');
            }

            if (in_array($key, $reservedDataKeys)
                || strpos($key, 'google') === 0
                || strpos($key, 'gcm') === 0
            ) {
                throw new \InvalidArgumentException(sprintf(
                    'The key "%s" is reserved or not recommended. Do not use it as data key.',
                    $key
                ));
            }

        }

        $this->data = $data;

        return $this;
    }
public function setData(array $data)
    {
        $reservedDataKeys = array(
            'from',
            'notification',
            'to',
            'registration_ids',
            'collapse_key',
            'priority',
            'restricted_package_name',
            'content_available',
            'delay_while_idle',
            'dry_run',
            'time_to_live',
            'data',
        );

        foreach ($data as $key => $value) {

            if (!is_string($key)) {
                throw new \InvalidArgumentException('Data keys must be of type string in order to convert data in a valid JSON Object.');
            }

            if (in_array($key, $reservedDataKeys)
                || strpos($key, 'google') === 0
                || strpos($key, 'gcm') === 0
            ) {
                throw new \InvalidArgumentException(sprintf(
                    'The key "%s" is reserved or not recommended. Do not use it as data key.',
                    $key
                ));
            }

        }

        $this->data = $data;

        return $this;
    }
public function setData ( array $ data ) { $ reservedDataKeys = array ( 'from' , 'notification' , 'to' , 'registration_ids' , 'collapse_key' , 'priority' , 'restricted_package_name' , 'content_available' , 'delay_while_idle' , 'dry_run' , 'time_to_live' , 'data' , ) ; foreach ( $ data as $ key => $ value ) { if ( ! is_string ( $ key ) ) { throw new \ InvalidArgumentException ( 'Data keys must be of type string in order to convert data in a valid JSON Object.' ) ; } if ( in_array ( $ key , $ reservedDataKeys ) || strpos ( $ key , 'google' ) === 0 || strpos ( $ key , 'gcm' ) === 0 ) { throw new \ InvalidArgumentException ( sprintf ( 'The key "%s" is reserved or not recommended. Do not use it as data key.' , $ key ) ) ; } } $ this -> data = $ data ; return $ this ; }
Set the value of Data.

@param array $data

@return self
Set the value of Data .