protected static function checkLen(string $type, string $bytes): void
    {
        $expectedLength = 0;

        switch ($type) {
            case self::BIT_B64:
                $expectedLength = 8;
                break;
            case self::BIT_B32:
                $expectedLength = 4;
                break;
            case self::BIT_B16:
                $expectedLength = 2;
                break;
            case self::BIT_B16_SIGNED:
                $expectedLength = 2;
                break;
            case self::BIT_B8:
                $expectedLength = 1;
                break;
        }

        $length = strlen($bytes);

        if ($length !== $expectedLength) {
            throw new ProtocolException('unpack failed. string(raw) length is ' . $length . ' , TO ' . $type);
        }
    }
protected static function checkLen(string $type, string $bytes): void
    {
        $expectedLength = 0;

        switch ($type) {
            case self::BIT_B64:
                $expectedLength = 8;
                break;
            case self::BIT_B32:
                $expectedLength = 4;
                break;
            case self::BIT_B16:
                $expectedLength = 2;
                break;
            case self::BIT_B16_SIGNED:
                $expectedLength = 2;
                break;
            case self::BIT_B8:
                $expectedLength = 1;
                break;
        }

        $length = strlen($bytes);

        if ($length !== $expectedLength) {
            throw new ProtocolException('unpack failed. string(raw) length is ' . $length . ' , TO ' . $type);
        }
    }
protected static function checkLen ( string $ type , string $ bytes ) : void { $ expectedLength = 0 ; switch ( $ type ) { case self :: BIT_B64 : $ expectedLength = 8 ; break ; case self :: BIT_B32 : $ expectedLength = 4 ; break ; case self :: BIT_B16 : $ expectedLength = 2 ; break ; case self :: BIT_B16_SIGNED : $ expectedLength = 2 ; break ; case self :: BIT_B8 : $ expectedLength = 1 ; break ; } $ length = strlen ( $ bytes ) ; if ( $ length !== $ expectedLength ) { throw new ProtocolException ( 'unpack failed. string(raw) length is ' . $ length . ' , TO ' . $ type ) ; } }
check unpack bit is valid

@throws ProtocolException
check unpack bit is valid