/** * Whether level is matched. * * @param T_Auth $auth * @return bool */ function isSatisfiedBy($auth) { return (bool) ($this->level & $auth->getLevel()); /* bit-wise operator is used here so the constructor argument can be more than 1 level e.g. T_Auth::HUMAN|T_Auth::OBFUSCATED */ }
function testLevelCanBeChanged() { $auth = new T_Auth(T_Auth::HUMAN); $auth->setLevel(T_Auth::OBFUSCATED); $this->assertSame(T_Auth::OBFUSCATED, $auth->getLevel()); }