src/FreeDSx/Asn1/Type/BitStringType.php
public static function fromInteger(int $int, ?int $minLength = null)
    {
        $pieces = str_split(decbin($int), 8);
        $num = count($pieces);

        if ($num === 1 && strlen($pieces[0]) !== 8) {
            $pieces[0] = str_pad($pieces[0], 8, '0', STR_PAD_LEFT);
        } elseif ($num > 0 && strlen($pieces[$num - 1]) !== 8) {
            $pieces[$num - 1] = str_pad($pieces[$num - 1], 8, '0', STR_PAD_RIGHT);
        }

        $bitstring = implode('', $pieces);
        if ($minLength && strlen($bitstring) < $minLength) {
            $bitstring = str_pad($bitstring, $minLength, '0');
        }

        return new self($bitstring);
    }
public static function fromInteger(int $int, ?int $minLength = null)
    {
        $pieces = str_split(decbin($int), 8);
        $num = count($pieces);

        if ($num === 1 && strlen($pieces[0]) !== 8) {
            $pieces[0] = str_pad($pieces[0], 8, '0', STR_PAD_LEFT);
        } elseif ($num > 0 && strlen($pieces[$num - 1]) !== 8) {
            $pieces[$num - 1] = str_pad($pieces[$num - 1], 8, '0', STR_PAD_RIGHT);
        }

        $bitstring = implode('', $pieces);
        if ($minLength && strlen($bitstring) < $minLength) {
            $bitstring = str_pad($bitstring, $minLength, '0');
        }

        return new self($bitstring);
    }
public static function fromInteger ( int $ int , ? int $ minLength = null ) { $ pieces = str_split ( decbin ( $ int ) , 8 ) ; $ num = count ( $ pieces ) ; if ( $ num === 1 && strlen ( $ pieces [ 0 ] ) !== 8 ) { $ pieces [ 0 ] = str_pad ( $ pieces [ 0 ] , 8 , '0' , STR_PAD_LEFT ) ; } elseif ( $ num > 0 && strlen ( $ pieces [ $ num - 1 ] ) !== 8 ) { $ pieces [ $ num - 1 ] = str_pad ( $ pieces [ $ num - 1 ] , 8 , '0' , STR_PAD_RIGHT ) ; } $ bitstring = implode ( '' , $ pieces ) ; if ( $ minLength && strlen ( $ bitstring ) < $ minLength ) { $ bitstring = str_pad ( $ bitstring , $ minLength , '0' ) ; } return new self ( $ bitstring ) ; }
Construct the bit string from an integer.

@param int $int
@param int|null $minLength
@return BitStringType
Construct the bit string from an integer .