public function unpack()
    {
        // Get fully qualifed name from type url.
        $url_prifix_len = strlen(GPBUtil::TYPE_URL_PREFIX);
        if (substr($this->type_url, 0, $url_prifix_len) !=
                GPBUtil::TYPE_URL_PREFIX) {
            throw new \Exception(
                "Type url needs to be type.googleapis.com/fully-qulified");
        }
        $fully_qualifed_name =
            substr($this->type_url, $url_prifix_len);

        // Create message according to fully qualified name.
        $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
        $desc = $pool->getDescriptorByProtoName( ".".$fully_qualifed_name);
        if (is_null($desc)) {
            throw new \Exception("Class ".$fully_qualifed_name
                                     ." hasn't been added to descriptor pool");
        }
        $klass = $desc->getClass();
        $msg = new $klass();

        // Merge data into message.
        $msg->mergeFromString($this->value);
        return $msg;
    }
public function unpack()
    {
        // Get fully qualifed name from type url.
        $url_prifix_len = strlen(GPBUtil::TYPE_URL_PREFIX);
        if (substr($this->type_url, 0, $url_prifix_len) !=
                GPBUtil::TYPE_URL_PREFIX) {
            throw new \Exception(
                "Type url needs to be type.googleapis.com/fully-qulified");
        }
        $fully_qualifed_name =
            substr($this->type_url, $url_prifix_len);

        // Create message according to fully qualified name.
        $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
        $desc = $pool->getDescriptorByProtoName( ".".$fully_qualifed_name);
        if (is_null($desc)) {
            throw new \Exception("Class ".$fully_qualifed_name
                                     ." hasn't been added to descriptor pool");
        }
        $klass = $desc->getClass();
        $msg = new $klass();

        // Merge data into message.
        $msg->mergeFromString($this->value);
        return $msg;
    }
public function unpack ( ) { // Get fully qualifed name from type url. $ url_prifix_len = strlen ( GPBUtil :: TYPE_URL_PREFIX ) ; if ( substr ( $ this -> type_url , 0 , $ url_prifix_len ) != GPBUtil :: TYPE_URL_PREFIX ) { throw new \ Exception ( "Type url needs to be type.googleapis.com/fully-qulified" ) ; } $ fully_qualifed_name = substr ( $ this -> type_url , $ url_prifix_len ) ; // Create message according to fully qualified name. $ pool = \ Google \ Protobuf \ Internal \ DescriptorPool :: getGeneratedPool ( ) ; $ desc = $ pool -> getDescriptorByProtoName ( "." . $ fully_qualifed_name ) ; if ( is_null ( $ desc ) ) { throw new \ Exception ( "Class " . $ fully_qualifed_name . " hasn't been added to descriptor pool" ) ; } $ klass = $ desc -> getClass ( ) ; $ msg = new $ klass ( ) ; // Merge data into message. $ msg -> mergeFromString ( $ this -> value ) ; return $ msg ; }
This method will try to resolve the type_url in Any message to get the
targeted message type. If failed, an error will be thrown. Otherwise,
the method will create a message of the targeted type and fill it with
the decoded value in Any.
@return unpacked message
@throws \Exception Type url needs to be type.googleapis.com/fully-qulified.
@throws \Exception Class hasn't been added to descriptor pool.
@throws \Exception cannot decode data in value field.
This method will try to resolve the type_url in Any message to get the targeted message type . If failed an error will be thrown . Otherwise the method will create a message of the targeted type and fill it with the decoded value in Any .