PubSub/src/IncomingMessageTrait.php
private function messageFactory(array $message, ConnectionInterface $connection, $projectId, $encode)
    {
        if (!isset($message['message'])) {
            throw new GoogleException('Invalid message data.');
        }

        if (isset($message['message']['data']) && $encode) {
            $message['message']['data'] = base64_decode($message['message']['data']);
        }

        $subscription = null;
        if (isset($message['subscription'])) {
            $subscription = new Subscription(
                $connection,
                $projectId,
                $message['subscription'],
                null,
                $encode
            );
        }

        return new Message($message['message'], [
            'ackId' => (isset($message['ackId'])) ? $message['ackId'] : null,
            'subscription' => $subscription
        ]);
    }
private function messageFactory(array $message, ConnectionInterface $connection, $projectId, $encode)
    {
        if (!isset($message['message'])) {
            throw new GoogleException('Invalid message data.');
        }

        if (isset($message['message']['data']) && $encode) {
            $message['message']['data'] = base64_decode($message['message']['data']);
        }

        $subscription = null;
        if (isset($message['subscription'])) {
            $subscription = new Subscription(
                $connection,
                $projectId,
                $message['subscription'],
                null,
                $encode
            );
        }

        return new Message($message['message'], [
            'ackId' => (isset($message['ackId'])) ? $message['ackId'] : null,
            'subscription' => $subscription
        ]);
    }
private function messageFactory ( array $ message , ConnectionInterface $ connection , $ projectId , $ encode ) { if ( ! isset ( $ message [ 'message' ] ) ) { throw new GoogleException ( 'Invalid message data.' ) ; } if ( isset ( $ message [ 'message' ] [ 'data' ] ) && $ encode ) { $ message [ 'message' ] [ 'data' ] = base64_decode ( $ message [ 'message' ] [ 'data' ] ) ; } $ subscription = null ; if ( isset ( $ message [ 'subscription' ] ) ) { $ subscription = new Subscription ( $ connection , $ projectId , $ message [ 'subscription' ] , null , $ encode ) ; } return new Message ( $ message [ 'message' ] , [ 'ackId' => ( isset ( $ message [ 'ackId' ] ) ) ? $ message [ 'ackId' ] : null , 'subscription' => $ subscription ] ) ; }
Create a Message instance from an incoming message.

@param array $message The message data
@param ConnectionInterface $connection The service connection.
@param string $projectId The current project ID.
@param bool $encode Whether to base64_encode.
@return Message
Create a Message instance from an incoming message .