Google\Cloud\PubSub\Topic::__construct PHP Method

__construct() public method

Create a PubSub topic.
public __construct ( Google\Cloud\PubSub\Connection\ConnectionInterface $connection, string $projectId, string $name, boolean $encode, array $info = null )
$connection Google\Cloud\PubSub\Connection\ConnectionInterface A connection to the Google Cloud Platform service
$projectId string The project Id
$name string The topic name
$encode boolean Whether messages should be base64 encoded.
$info array [optional] A [Topic](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics)
    public function __construct(ConnectionInterface $connection, $projectId, $name, $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('topic', $name)) {
            $this->name = $name;
        } else {
            $this->name = $this->formatName('topic', $name, $projectId);
        }
        $iamConnection = new IamTopic($this->connection);
        $this->iam = new Iam($iamConnection, $this->name);
    }