Storage/src/Bucket.php
private function getFormattedTopic($topic)
    {
        if ($topic instanceof Topic) {
            return sprintf(self::NOTIFICATION_TEMPLATE, $topic->name());
        }

        if (!is_string($topic)) {
            throw new \InvalidArgumentException(
                '$topic may only be a string or instance of Google\Cloud\PubSub\Topic'
            );
        }

        if (preg_match('/projects\/[^\/]*\/topics\/(.*)/', $topic) === 1) {
            return sprintf(self::NOTIFICATION_TEMPLATE, $topic);
        }

        if (!$this->projectId) {
            throw new GoogleException(
                'No project ID was provided, ' .
                'and we were unable to detect a default project ID.'
            );
        }

        return sprintf(
            self::NOTIFICATION_TEMPLATE,
            sprintf(self::TOPIC_TEMPLATE, $this->projectId, $topic)
        );
    }
private function getFormattedTopic($topic)
    {
        if ($topic instanceof Topic) {
            return sprintf(self::NOTIFICATION_TEMPLATE, $topic->name());
        }

        if (!is_string($topic)) {
            throw new \InvalidArgumentException(
                '$topic may only be a string or instance of Google\Cloud\PubSub\Topic'
            );
        }

        if (preg_match('/projects\/[^\/]*\/topics\/(.*)/', $topic) === 1) {
            return sprintf(self::NOTIFICATION_TEMPLATE, $topic);
        }

        if (!$this->projectId) {
            throw new GoogleException(
                'No project ID was provided, ' .
                'and we were unable to detect a default project ID.'
            );
        }

        return sprintf(
            self::NOTIFICATION_TEMPLATE,
            sprintf(self::TOPIC_TEMPLATE, $this->projectId, $topic)
        );
    }
private function getFormattedTopic ( $ topic ) { if ( $ topic instanceof Topic ) { return sprintf ( self :: NOTIFICATION_TEMPLATE , $ topic -> name ( ) ) ; } if ( ! is_string ( $ topic ) ) { throw new \ InvalidArgumentException ( '$topic may only be a string or instance of Google\Cloud\PubSub\Topic' ) ; } if ( preg_match ( '/projects\/[^\/]*\/topics\/(.*)/' , $ topic ) === 1 ) { return sprintf ( self :: NOTIFICATION_TEMPLATE , $ topic ) ; } if ( ! $ this -> projectId ) { throw new GoogleException ( 'No project ID was provided, ' . 'and we were unable to detect a default project ID.' ) ; } return sprintf ( self :: NOTIFICATION_TEMPLATE , sprintf ( self :: TOPIC_TEMPLATE , $ this -> projectId , $ topic ) ) ; }
Return a topic name in its fully qualified format.

@param Topic|string $topic
@return string
@throws \InvalidArgumentException
@throws GoogleException
Return a topic name in its fully qualified format .