PubSub/src/Subscription.php
public function pull(array $options = [])
    {
        $messages = [];
        $options['returnImmediately'] = isset($options['returnImmediately'])
            ? $options['returnImmediately']
            : false;
        $options['maxMessages'] = isset($options['maxMessages'])
            ? $options['maxMessages']
            : self::MAX_MESSAGES;

        $response = $this->connection->pull($options + [
            'subscription' => $this->name
        ]);

        if (isset($response['receivedMessages'])) {
            foreach ($response['receivedMessages'] as $message) {
                $messages[] = $this->messageFactory($message, $this->connection, $this->projectId, $this->encode);
            }
        }

        return $messages;
    }
public function pull(array $options = [])
    {
        $messages = [];
        $options['returnImmediately'] = isset($options['returnImmediately'])
            ? $options['returnImmediately']
            : false;
        $options['maxMessages'] = isset($options['maxMessages'])
            ? $options['maxMessages']
            : self::MAX_MESSAGES;

        $response = $this->connection->pull($options + [
            'subscription' => $this->name
        ]);

        if (isset($response['receivedMessages'])) {
            foreach ($response['receivedMessages'] as $message) {
                $messages[] = $this->messageFactory($message, $this->connection, $this->projectId, $this->encode);
            }
        }

        return $messages;
    }
public function pull ( array $ options = [ ] ) { $ messages = [ ] ; $ options [ 'returnImmediately' ] = isset ( $ options [ 'returnImmediately' ] ) ? $ options [ 'returnImmediately' ] : false ; $ options [ 'maxMessages' ] = isset ( $ options [ 'maxMessages' ] ) ? $ options [ 'maxMessages' ] : self :: MAX_MESSAGES ; $ response = $ this -> connection -> pull ( $ options + [ 'subscription' => $ this -> name ] ) ; if ( isset ( $ response [ 'receivedMessages' ] ) ) { foreach ( $ response [ 'receivedMessages' ] as $ message ) { $ messages [ ] = $ this -> messageFactory ( $ message , $ this -> connection , $ this -> projectId , $ this -> encode ) ; } } return $ messages ; }
Retrieve new messages from the topic.

Example:
```
$messages = $subscription->pull();
foreach ($messages as $message) {
echo $message->data();
}
```

@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull Pull Subscriptions

@param array $options [optional] {
Configuration Options

@type bool $returnImmediately If true, the system will respond
immediately, even if no messages are available. Otherwise,
wait until new messages are available. **Defaults to**
`false`.
@type int $maxMessages Limit the amount of messages pulled.
**Defaults to** `1000`.
}
@return Message[]
Retrieve new messages from the topic .