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];
    }