src/CFPropertyList/CFBinaryPropertyList.php
protected function readBinaryInt($length)
    {
        if ($length > 3) {
            throw new PListException("Integer greater than 8 bytes: $length");
        }

        $nbytes = 1 << $length;

        $val = null;
        if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
            throw IOException::readError("");
        }
        $this->pos += $nbytes;

        switch ($length) {
            case 0:
                $val = unpack("C", $buff);
                $val = $val[1];
                break;
            case 1:
                $val = unpack("n", $buff);
                $val = $val[1];
                break;
            case 2:
                $val = unpack("N", $buff);
                $val = $val[1];
                break;
            case 3:
                $words = unpack("Nhighword/Nlowword", $buff);
              //$val = $words['highword'] << 32 | $words['lowword'];
                $val = self::make64Int($words['highword'], $words['lowword']);
                break;
        }

        return new CFNumber($val);
    }
protected function readBinaryInt($length)
    {
        if ($length > 3) {
            throw new PListException("Integer greater than 8 bytes: $length");
        }

        $nbytes = 1 << $length;

        $val = null;
        if (strlen($buff = substr($this->content, $this->pos, $nbytes)) != $nbytes) {
            throw IOException::readError("");
        }
        $this->pos += $nbytes;

        switch ($length) {
            case 0:
                $val = unpack("C", $buff);
                $val = $val[1];
                break;
            case 1:
                $val = unpack("n", $buff);
                $val = $val[1];
                break;
            case 2:
                $val = unpack("N", $buff);
                $val = $val[1];
                break;
            case 3:
                $words = unpack("Nhighword/Nlowword", $buff);
              //$val = $words['highword'] << 32 | $words['lowword'];
                $val = self::make64Int($words['highword'], $words['lowword']);
                break;
        }

        return new CFNumber($val);
    }
protected function readBinaryInt ( $ length ) { if ( $ length > 3 ) { throw new PListException ( "Integer greater than 8 bytes: $length" ) ; } $ nbytes = 1 << $ length ; $ val = null ; if ( strlen ( $ buff = substr ( $ this -> content , $ this -> pos , $ nbytes ) ) != $ nbytes ) { throw IOException :: readError ( "" ) ; } $ this -> pos += $ nbytes ; switch ( $ length ) { case 0 : $ val = unpack ( "C" , $ buff ) ; $ val = $ val [ 1 ] ; break ; case 1 : $ val = unpack ( "n" , $ buff ) ; $ val = $ val [ 1 ] ; break ; case 2 : $ val = unpack ( "N" , $ buff ) ; $ val = $ val [ 1 ] ; break ; case 3 : $ words = unpack ( "Nhighword/Nlowword" , $ buff ) ; //$val = $words['highword'] << 32 | $words['lowword']; $ val = self :: make64Int ( $ words [ 'highword' ] , $ words [ 'lowword' ] ) ; break ; } return new CFNumber ( $ val ) ; }
Read an integer value
@param integer $length The length (in bytes) of the integer value, coded as „set bit $length to 1”
@return CFNumber The integer value
@throws PListException if integer val is invalid
@throws IOException if read error occurs
@uses make64Int() to overcome PHP's big integer problems
Read an integer value