PHPZip\Zip\Core\ZipUtils::setBit PHP Method

setBit() public static method

public static setBit ( &$data, $bit, $value = true )
    public static function setBit(&$data, $bit, $value = true) {
        if ($value) {
            $data |= (1 << $bit);
        } else {
            self::clrBit($data, $bit);
        }

    }

Usage Example

 /**
  * @return string The version of the field for the Central Header.
  */
 public function getCentralField()
 {
     $ts = $this->isModTimeSet ? pack('V', $this->modTime) : '';
     $flags = 0;
     ZipUtils::setBit($flags, 0, $this->isModTimeSet);
     ZipUtils::setBit($flags, 1, $this->isAcTimeSet);
     ZipUtils::setBit($flags, 2, $this->isCrTimeSet);
     return parent::HEADER_EXTENDED_TIMESTAMP . pack('vc', 1 + ZipUtils::bin_strlen($ts), $flags) . $ts;
 }