zendframework/zf2 — pull request #4940 by corentin-larose (2013-08-09 13:44:51+00:00)
Title: New Zend\Validator\Bitwise

Usage:

```php
$controlSum,
'operator' => Bitwise::OP_AND,
'strict' => false
));

// or
$validator = new Bitwise();
$validator->setControl($controlSum);
$validator->setOperator(Bitwise::OP_AND);
$validator->setStrict(false); // Default value, just for example

// Does my value has at least one allowed bit set ?
$validator = new Bitwise($controlSum, Bitwise::OP_AND, false);
$validator->isValid(0x1); // true
$validator->isValid(0x2); // true
$validator->isValid(0x4); // true
$validator->isValid(0x1 | 0x8); // true since strict option is set to false by default
$validator->isValid(0x8); // false

// Does my value has only allowed bits set ?
$validator = new Bitwise($controlSum, Bitwise::OP_AND, true);
$validator->isValid(0x1); // true
$validator->isValid(0x2); // true
$validator->isValid(0x4); // true
$validator->isValid(0x1 | 0x8); // false since strict option is set to true
$validator->isValid(0x8); // false

// Does my value has only not allowed bit sets ?
$validator = new Bitwise($controlSum, Bitwise::OP_XOR);
$validator->isValid(0x1); // false
$validator->isValid(0x2); // false
$validator->isValid(0x4); // false
$validator->isValid(0x1 | 0x8); // false
$validator->isValid(0x8); // true
```