src/Decoder.php
private function decodeDict()
    {
        $dict = array();
        $terminated = false;
        $dictOffset = $this->offset;

        while (false !== $this->getChar()) {
            if ("e" == $this->getChar()) {
                $terminated = true;
                break;
            }

            $keyOffset = $this->offset;
            if (!ctype_digit($this->getChar())) {
                throw new RuntimeException("Invalid dictionary key at offset $keyOffset");
            }

            $key = $this->decodeString();
            if (isset ($dict[$key])) {
                throw new RuntimeException("Duplicate dictionary key at offset $keyOffset");
            }

            $dict[$key] = $this->doDecode();
        }

        if (!$terminated && false === $this->getChar()) {
            throw new RuntimeException("Unterminated dictionary definition at offset $dictOffset");
        }

        $this->offset++;

        return $dict;
    }
private function decodeDict()
    {
        $dict = array();
        $terminated = false;
        $dictOffset = $this->offset;

        while (false !== $this->getChar()) {
            if ("e" == $this->getChar()) {
                $terminated = true;
                break;
            }

            $keyOffset = $this->offset;
            if (!ctype_digit($this->getChar())) {
                throw new RuntimeException("Invalid dictionary key at offset $keyOffset");
            }

            $key = $this->decodeString();
            if (isset ($dict[$key])) {
                throw new RuntimeException("Duplicate dictionary key at offset $keyOffset");
            }

            $dict[$key] = $this->doDecode();
        }

        if (!$terminated && false === $this->getChar()) {
            throw new RuntimeException("Unterminated dictionary definition at offset $dictOffset");
        }

        $this->offset++;

        return $dict;
    }
private function decodeDict ( ) { $ dict = array ( ) ; $ terminated = false ; $ dictOffset = $ this -> offset ; while ( false !== $ this -> getChar ( ) ) { if ( "e" == $ this -> getChar ( ) ) { $ terminated = true ; break ; } $ keyOffset = $ this -> offset ; if ( ! ctype_digit ( $ this -> getChar ( ) ) ) { throw new RuntimeException ( "Invalid dictionary key at offset $keyOffset" ) ; } $ key = $ this -> decodeString ( ) ; if ( isset ( $ dict [ $ key ] ) ) { throw new RuntimeException ( "Duplicate dictionary key at offset $keyOffset" ) ; } $ dict [ $ key ] = $ this -> doDecode ( ) ; } if ( ! $ terminated && false === $ this -> getChar ( ) ) { throw new RuntimeException ( "Unterminated dictionary definition at offset $dictOffset" ) ; } $ this -> offset ++ ; return $ dict ; }
Decode a bencode encoded dictionary

@return array   Returns the decoded array.
@throws RuntimeException
Decode a bencode encoded dictionary