Google\Cloud\PubSub\Subscription::__construct PHP Méthode

__construct() public méthode

The idiomatic way to use this class is through the PubSubClient or Topic, but you can instantiate it directly as well.
public __construct ( Google\Cloud\PubSub\Connection\ConnectionInterface $connection, string $projectId, string $name, string $topicName, boolean $encode, array $info = null )
$connection Google\Cloud\PubSub\Connection\ConnectionInterface The service connection object
$projectId string The current project
$name string The subscription name
$topicName string The topic name the subscription is attached to
$encode boolean Whether messages are encrypted or not.
$info array [optional] Subscription info. Used to pre-populate the object.
    public function __construct(ConnectionInterface $connection, $projectId, $name, $topicName, $encode, array $info = null)
    {
        $this->connection = $connection;
        $this->projectId = $projectId;
        $this->encode = (bool) $encode;
        $this->info = $info;
        // Accept either a simple name or a fully-qualified name.
        if ($this->isFullyQualifiedName('subscription', $name)) {
            $this->name = $name;
        } else {
            $this->name = $this->formatName('subscription', $name, $projectId);
        }
        // Accept either a simple name or a fully-qualified name.
        if ($this->isFullyQualifiedName('topic', $topicName)) {
            $this->topicName = $topicName;
        } else {
            $this->topicName = !is_null($topicName) ? $this->formatName('topic', $topicName, $projectId) : null;
        }
        $iamConnection = new IamSubscription($this->connection);
        $this->iam = new Iam($iamConnection, $this->name);
    }