| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
class CJTAttributes { |
| 10 |
|
| 11 |
/** |
| 12 |
* put your comment there... |
| 13 |
* |
| 14 |
* @var mixed |
| 15 |
*/ |
| 16 |
protected $flags; |
| 17 |
|
| 18 |
/** |
| 19 |
* put your comment there... |
| 20 |
* |
| 21 |
* @var mixed |
| 22 |
*/ |
| 23 |
protected $resetDefault; |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
* @param mixed $init |
| 29 |
*/ |
| 30 |
public function __construct($initFlags = 0, $resetDefault = 0) { |
| 31 |
$this->flags = $initFlags; |
| 32 |
$this->resetDefault = $resetDefault; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* put your comment there... |
| 37 |
* |
| 38 |
* @param mixed $flag |
| 39 |
*/ |
| 40 |
public function isOff($flag) { |
| 41 |
return !$this->isOn($flag); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* put your comment there... |
| 46 |
* |
| 47 |
* @param mixed $flag |
| 48 |
*/ |
| 49 |
public function isOn($flag) { |
| 50 |
return $this->flags & $flag; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* put your comment there... |
| 55 |
* |
| 56 |
* @param mixed $flag |
| 57 |
*/ |
| 58 |
public function off($flag) { |
| 59 |
$this->flags &= (~$flag); // All other flags are ON except our! |
| 60 |
return $this; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* put your comment there... |
| 65 |
* |
| 66 |
* @param mixed $flag |
| 67 |
*/ |
| 68 |
public function on($flag) { |
| 69 |
$this->flags &= $flag; // All other flag are OFF except our! |
| 70 |
return $this; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* put your comment there... |
| 75 |
* |
| 76 |
*/ |
| 77 |
public function reset() { |
| 78 |
$this->flags = $this->resetDefault; |
| 79 |
return $this; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* put your comment there... |
| 84 |
* |
| 85 |
* @param mixed $flag |
| 86 |
*/ |
| 87 |
public function revert($flag) { |
| 88 |
$this->flags ^= $flag; // XOR |
| 89 |
return $this; |
| 90 |
} |
| 91 |
|
| 92 |
} // End class. |
| 93 |
|