1. Go to this page and download the library: Download axetools/bitflagtrait library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
axetools / bitflagtrait example snippets
class ShippingStatus {
use AxeTools\Traits\BitFlag\BitFlagTrait;
const FLAG_RECEIVED = 0b00001; // int value 1
const FLAG_QUEUED = 0b00010; // int value 2
const FLAG_SHIPPED = 0b00100; // int value 4
private $status = 0;
public function __construct($status){
$this->status = $status;
}
public function hasShipped(){
return self::hasFlag($this->status, self::FLAG_SHIPPED);
}
}
$orderStatus = new ShippingStatus(ShippingStatus::FLAG_RECEIVED | ShippingStatus::FLAG_QUEUED);
var_dump($orderStatus->hasShipped()); // false
$orderStatus = new ShippingStatus(3);
var_dump($orderStatus->hasShipped()); // false
$orderStatus = new ShippingStatus(7);
var_dump($orderStatus->hasShipped()); // true
self::hasFlag(int $flagSet, int $flag): bool
self::setFlag(int &$flagSet, int $flag, bool $value): void
self::toggleFlag(int &$flagSet, int $flag): void
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.