FOF30\TransparentAuthentication\TransparentAuthentication::removeAuthenticationMethod PHP Méthode

removeAuthenticationMethod() public méthode

Disable an authentication method
public removeAuthenticationMethod ( integer $method )
$method integer
    public function removeAuthenticationMethod($method)
    {
        if (in_array($method, $this->authenticationMethods)) {
            $key = array_search($method, $this->authenticationMethods);
            unset($this->authenticationMethods[$key]);
        }
    }

Usage Example

 public function testRemoveAuthenticationMethod()
 {
     $this->auth->setAuthenticationMethods(array(TransparentAuthentication::Auth_HTTPBasicAuth_Plaintext, TransparentAuthentication::Auth_HTTPBasicAuth_TOTP));
     // Try removing a non-existing method
     $this->auth->removeAuthenticationMethod(TransparentAuthentication::Auth_QueryString_Plaintext);
     $this->assertEquals(array(TransparentAuthentication::Auth_HTTPBasicAuth_Plaintext, TransparentAuthentication::Auth_HTTPBasicAuth_TOTP), ReflectionHelper::getValue($this->auth, 'authenticationMethods'));
     // Try removing an existing method
     $this->auth->removeAuthenticationMethod(TransparentAuthentication::Auth_HTTPBasicAuth_Plaintext);
     $this->assertEquals(array(1 => TransparentAuthentication::Auth_HTTPBasicAuth_TOTP), ReflectionHelper::getValue($this->auth, 'authenticationMethods'));
 }