PubSub/src/Topic.php
private function formatMessage(array $message)
    {
        if (isset($message['data']) && $this->encode) {
            $message['data'] = base64_encode($message['data']);
        }

        if (!array_key_exists('data', $message) &&
            !array_key_exists('attributes', $message)) {
            throw new InvalidArgumentException('At least one of $data or
                $attributes must be specified on each message, but neither
                was given.');
        }

        return $message;
    }
private function formatMessage(array $message)
    {
        if (isset($message['data']) && $this->encode) {
            $message['data'] = base64_encode($message['data']);
        }

        if (!array_key_exists('data', $message) &&
            !array_key_exists('attributes', $message)) {
            throw new InvalidArgumentException('At least one of $data or
                $attributes must be specified on each message, but neither
                was given.');
        }

        return $message;
    }
private function formatMessage ( array $ message ) { if ( isset ( $ message [ 'data' ] ) && $ this -> encode ) { $ message [ 'data' ] = base64_encode ( $ message [ 'data' ] ) ; } if ( ! array_key_exists ( 'data' , $ message ) && ! array_key_exists ( 'attributes' , $ message ) ) { throw new InvalidArgumentException ( 'At least one of $data or
                $attributes must be specified on each message, but neither
                was given.' ) ; } return $ message ; }
Ensure that the message is in a correct format,
base64_encode the data, and error if the input is too wrong to proceed.

@param  array $message
@return array The message data
@throws \InvalidArgumentException
Ensure that the message is in a correct format base64_encode the data and error if the input is too wrong to proceed .