示例#1
0
 public function testToInteger()
 {
     $flags = new Flags(['first', 'second', 'third']);
     $array = $flags->toArray($flags->getFlag('first') | $flags->getFlag('third'));
     $integer = $flags->toInteger($array);
     $this->assertEquals(0b101, $integer);
 }
示例#2
0
 /**
  * Checks whether user has supplied privileges.
  * @param int [...] sets of privileges to check
  * @return bool true if no privileges are supplied or if at least
  * one supplied set of privileges is matched with user's privileges
  */
 public function hasPrivileges(...$setsOfPrivileges)
 {
     if ($this->isLogged()) {
         return Flags::match($this->data['privileges'], ...$setsOfPrivileges);
     }
     return false;
 }