PubSub/src/Subscription.php
public function create(array $options = [])
    {
        // If a subscription is created via PubSubClient::subscription(),
        // it may or may not have a topic name. This is fine for most API
        // interactions, but a topic name is required to create a subscription.
        if (!$this->topicName) {
            throw new InvalidArgumentException('A topic name is required to
                create a subscription.');
        }

        $this->info = $this->connection->createSubscription($options + [
            'name' => $this->name,
            'topic' => $this->topicName
        ]);

        return $this->info;
    }
public function create(array $options = [])
    {
        // If a subscription is created via PubSubClient::subscription(),
        // it may or may not have a topic name. This is fine for most API
        // interactions, but a topic name is required to create a subscription.
        if (!$this->topicName) {
            throw new InvalidArgumentException('A topic name is required to
                create a subscription.');
        }

        $this->info = $this->connection->createSubscription($options + [
            'name' => $this->name,
            'topic' => $this->topicName
        ]);

        return $this->info;
    }
public function create ( array $ options = [ ] ) { // If a subscription is created via PubSubClient::subscription(), // it may or may not have a topic name. This is fine for most API // interactions, but a topic name is required to create a subscription. if ( ! $ this -> topicName ) { throw new InvalidArgumentException ( 'A topic name is required to
                create a subscription.' ) ; } $ this -> info = $ this -> connection -> createSubscription ( $ options + [ 'name' => $ this -> name , 'topic' => $ this -> topicName ] ) ; return $ this -> info ; }
Execute a service request creating the subscription.

The suggested way of creating a subscription is by calling through
{@see Google\Cloud\PubSub\Topic::subscribe()} or {@see Google\Cloud\PubSub\Topic::subscription()}.

Returns subscription info in the format detailed in the documentation
for a [subscription](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#Subscription).

**NOTE: Some methods of instantiation of a Subscription do not supply a
topic name. The topic name is required to create a subscription.**

Example:
```
$topic = $pubsub->topic('my-new-topic');

$subscription = $topic->subscription('my-new-subscription');
$result = $subscription->create();
```

@see https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create Create Subscription

@param array $options [optional] {
Configuration Options

For information regarding the push configuration settings, see
[PushConfig](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#PushConfig).

@type string $pushConfig.pushEndpoint A URL locating the endpoint to which
messages should be pushed. For example, a Webhook endpoint
might use "https://example.com/push".
@type array $pushConfig.attributes Endpoint configuration attributes.
@type int $ackDeadlineSeconds The maximum time after a subscriber
receives a message before the subscriber should acknowledge the
message.
@type bool $retainAckedMessages Indicates whether to retain
acknowledged messages.
@type Duration $messageRetentionDuration How long to retain
unacknowledged messages in the subscription's backlog, from the
moment a message is published. If `$retainAckedMessages` is
true, then this also configures the retention of acknowledged
messages, and thus configures how far back in time a `Seek`
can be done. Cannot be more than 7 days or less than 10 minutes.
**Defaults to** 7 days.
}
@return array An array of subscription info
@throws \InvalidArgumentException
Execute a service request creating the subscription .