Return a `Subscription` instance from a channel name.

If the subscription doesn't exist, the subscription is first created.

@param string $channel

@return \Google\Cloud\PubSub\Subscription
324901
protected function getSubscriptionForChannel($channel)
    {
        $topic = $this->getTopicForChannel($channel);
        $clientIdentifier = $this->clientIdentifier ? $this->clientIdentifier : 'default';
        $clientIdentifier .= '.' . $channel;
        $subscription = $topic->subscription($clientIdentifier);
        if ($this->autoCreateSubscriptions && !$subscription->exists()) {
            $subscription->create();
        }
        return $subscription;
    }
395345
private function _GrpcUnaryUnary($channel)
    {
        return function ($method,
                         $argument,
                         $deserialize,
                         array $metadata = [],
                         array $options = []) use ($channel) {
            $call = $this->call_invoker->UnaryCall(
                $channel,
                $method,
                $deserialize,
                $options
            );
            $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
            if (is_callable($this->update_metadata)) {
                $metadata = call_user_func(
                    $this->update_metadata,
                    $metadata,
                    $jwt_aud_uri
                );
            }
            $metadata = $this->_validate_and_normalize_metadata(
                $metadata
            );
            $call->start($argument, $metadata, $options);
            return $call;
        };
    }
314762
public function getLogger($channel = 'default')
    {
        if (isset($this->loggers[$channel])) {
            return $this->loggers[$channel];
        }

        /** @var Logger $logger */
        $logger = $this->getContainer()->get(LoggerInterface::class, [$channel]);

        $this->loggers[$channel] = $logger;

        /** @var LoggerInterface $contract */
        $contract = $this->validateContract($this->loggers[$channel], LoggerInterface::class);
        return $contract;
    }
447227
public function updateChannel(Channel $channel)
    {
        $op = $this->sendUpdateChannelOperation($channel);

        // waiting for create operation finishes
        $op = $this->awaitOperation($op);

        if ($op->getState() != OperationState::Succeeded) {
            return null;
        }

        // get and return the createChannel
        return $this->getChannel($channel->getId());
    }
252769
public function channelSubscriptionUser($channel, $user, $token = null)
    {
        return $this->sendRequest('GET', 'channels/'.$channel.'/subscriptions/'.$user, $this->getToken($token));
    }
233895
public function getOptions($channel)
    {
        $options = $this->defaults;

        if (isset($this->options[$channel])) {
            $options = array_merge(
                $options,
                $this->options[$channel]
            );
        }

        return $options;
    }
1115137
public function resetChannel($channel)
    {
        $op = $this->sendResetChannelOperation($channel);

        // waiting for reset operation finishes
        $op = $this->awaitOperation($op);

        // true if succeeded
        return $op->getState() == OperationState::Succeeded;
    }
353929
public function getChannel($channel)
    {
        $channelId = Utilities::getEntityId(
            $channel,
            'WindowsAzure\MediaServices\Models\Channel'
        );

        return Channel::createFromOptions($this->_getEntity("Channels('{$channelId}')"));
    }
1139612
public function getChannel(string $channel): Channel
    {
        if (!$this->channelExists($channel)) {
            throw new OutOfRangeException("The channel[{$channel}] not found");
        }

        return $this->channels[$channel];
    }
391195
private function _UnaryUnaryCallFactory($channel)
    {
        if (is_a($channel, 'Grpc\Internal\InterceptorChannel')) {
            return function ($method,
                             $argument,
                             $deserialize,
                             array $metadata = [],
                             array $options = []) use ($channel) {
                return $channel->getInterceptor()->interceptUnaryUnary(
                    $method,
                    $argument,
                    $deserialize,
                    $metadata,
                    $options,
                    $this->_UnaryUnaryCallFactory($channel->getNext())
                );
            };
        }
        return $this->_GrpcUnaryUnary($channel);
    }
135114
public function deleteChannel($channel)
    {
        $op = $this->sendDeleteChannelOperation($channel);

        // waiting for delete operation finishes
        $op = $this->awaitOperation($op);

        // true if succeeded
        return $op->getState() == OperationState::Succeeded;
    }
1298683
public function createLogger($channel)
    {
        Cascade::loadConfigFromArray($this->config);
        $logger = Cascade::getLogger($channel);
        $logger->pushProcessor(new PsrLogMessageProcessor());
        return $logger;
    }
501143
public static function getLogger(string $channel): Logger
    {
        if (empty(static::$loggers[$channel])) {
            static::$loggers[$channel] = new Logger($channel);
        }

        return static::$loggers[$channel];
    }
457641
public function pop($channel = '')
    {
        $channel = $channel ?: static::$defaultChannel;
        return $this->channelOrFail($channel)->pop($channel);
    }
1241351
private function _GrpcStreamStream($channel)
    {
        return function ($method,
                         $deserialize,
                         array $metadata = [],
                         array $options = []) use ($channel) {
            $call = $this->call_invoker->BidiStreamingCall(
                $channel,
                $method,
                $deserialize,
                $options
            );
            $jwt_aud_uri = $this->_get_jwt_aud_uri($method);
            if (is_callable($this->update_metadata)) {
                $metadata = call_user_func(
                    $this->update_metadata,
                    $metadata,
                    $jwt_aud_uri
                );
            }
            $metadata = $this->_validate_and_normalize_metadata(
                $metadata
            );
            $call->start($metadata);

            return $call;
        };
    }
528682
public function subscribe(string $channel): Promise {
        return call(function () use ($channel) {
            yield $this->connection->send(["subscribe", $channel]);

            $emitter = new Emitter;
            $this->emitters[$channel][\spl_object_hash($emitter)] = $emitter;

            return new Subscription($emitter->iterate(), function () use ($emitter, $channel) {
                $this->unloadEmitter($emitter, $channel);
            });
        });
    }
321649
public function sendUpdateChannelOperation(Channel $channel)
    {
        $channelId = $channel->getId();
        Validate::notNull($channelId, 'channelId');

        return $this->_sendOperation(
            $channel,
            "Channels('{$channelId}')",
            Resources::HTTP_MERGE,
            [Resources::STATUS_ACCEPTED, Resources::STATUS_NO_CONTENT]);
    }