public function decode($tnetstring)
    {
        if (! $tnetstring) {
            throw new InvalidArgumentException("Can't decode an empty tnetstring.");
        }

        $remaining = $tnetstring;
        $values    = array();

        while ($remaining) {
            list($size, $data) = explode(':', $remaining, 2);
            $size              = intval($size);
            $payload           = substr($data, 0, $size);
            $remaining         = substr($data, $size);

            if (! $remaining) {
                throw new RuntimeException(sprintf(
                    'The size of the payload "%s" (%d) isn\'t the same as specified (%d).',
                    $payload,
                    strlen($payload),
                    $size
                ));
            }

            $payloadType = $remaining[0];
            $remaining   = substr($remaining, 1);
            $values[]    = $this->convertPayloadToPHPValue($payload, $payloadType);
        }

        return count($values) > 1 ? $values : $values[0];
    }
public function decode($tnetstring)
    {
        if (! $tnetstring) {
            throw new InvalidArgumentException("Can't decode an empty tnetstring.");
        }

        $remaining = $tnetstring;
        $values    = array();

        while ($remaining) {
            list($size, $data) = explode(':', $remaining, 2);
            $size              = intval($size);
            $payload           = substr($data, 0, $size);
            $remaining         = substr($data, $size);

            if (! $remaining) {
                throw new RuntimeException(sprintf(
                    'The size of the payload "%s" (%d) isn\'t the same as specified (%d).',
                    $payload,
                    strlen($payload),
                    $size
                ));
            }

            $payloadType = $remaining[0];
            $remaining   = substr($remaining, 1);
            $values[]    = $this->convertPayloadToPHPValue($payload, $payloadType);
        }

        return count($values) > 1 ? $values : $values[0];
    }
public function decode ( $ tnetstring ) { if ( ! $ tnetstring ) { throw new InvalidArgumentException ( "Can't decode an empty tnetstring." ) ; } $ remaining = $ tnetstring ; $ values = array ( ) ; while ( $ remaining ) { list ( $ size , $ data ) = explode ( ':' , $ remaining , 2 ) ; $ size = intval ( $ size ) ; $ payload = substr ( $ data , 0 , $ size ) ; $ remaining = substr ( $ data , $ size ) ; if ( ! $ remaining ) { throw new RuntimeException ( sprintf ( 'The size of the payload "%s" (%d) isn\'t the same as specified (%d).' , $ payload , strlen ( $ payload ) , $ size ) ) ; } $ payloadType = $ remaining [ 0 ] ; $ remaining = substr ( $ remaining , 1 ) ; $ values [ ] = $ this -> convertPayloadToPHPValue ( $ payload , $ payloadType ) ; } return count ( $ values ) > 1 ? $ values : $ values [ 0 ] ; }
Decodes the value or values from the tagged netstring.

Note well that if the tagged netstring is a single encoded value, then
that value will be returned. If the tagged netstring is a collection of
encoded values those values will be returned as an array.

@param string $tnetstring
@return mixed The decoded value or values
@throws InvalidArgumentException If the tagged netstring is an empty
string
@throws RuntimeException If the tagged netstring is incorrectly encoded
Decodes the value or values from the tagged netstring .