public function tokenize(array $credentials)
    {
        if (empty($credentials)) {
            throw new AuthenticationException('Unable to create token, no or empty credentials');
        }

        foreach ($this->providers as $provider) {
            if (!$provider->supportsCredentials($credentials)) {
                continue;
            }

            if (!$token = $provider->tokenize($credentials)) {
                $this->stash()
                     ->destroy();

                throw new AuthenticationException(sprintf('Unable to create token, credentials could not be authenticated in provider "%s"', get_class($provider)));
            }

            $this->stash()
                 ->put($token);

            return $this;
        }

        $this->stash()
             ->destroy();

        throw new AuthenticationException(sprintf('Unable to create token, missing provider supporting credentials "%s"', implode(', ', array_keys($credentials))));
    }
public function tokenize(array $credentials)
    {
        if (empty($credentials)) {
            throw new AuthenticationException('Unable to create token, no or empty credentials');
        }

        foreach ($this->providers as $provider) {
            if (!$provider->supportsCredentials($credentials)) {
                continue;
            }

            if (!$token = $provider->tokenize($credentials)) {
                $this->stash()
                     ->destroy();

                throw new AuthenticationException(sprintf('Unable to create token, credentials could not be authenticated in provider "%s"', get_class($provider)));
            }

            $this->stash()
                 ->put($token);

            return $this;
        }

        $this->stash()
             ->destroy();

        throw new AuthenticationException(sprintf('Unable to create token, missing provider supporting credentials "%s"', implode(', ', array_keys($credentials))));
    }
public function tokenize ( array $ credentials ) { if ( empty ( $ credentials ) ) { throw new AuthenticationException ( 'Unable to create token, no or empty credentials' ) ; } foreach ( $ this -> providers as $ provider ) { if ( ! $ provider -> supportsCredentials ( $ credentials ) ) { continue ; } if ( ! $ token = $ provider -> tokenize ( $ credentials ) ) { $ this -> stash ( ) -> destroy ( ) ; throw new AuthenticationException ( sprintf ( 'Unable to create token, credentials could not be authenticated in provider "%s"' , get_class ( $ provider ) ) ) ; } $ this -> stash ( ) -> put ( $ token ) ; return $ this ; } $ this -> stash ( ) -> destroy ( ) ; throw new AuthenticationException ( sprintf ( 'Unable to create token, missing provider supporting credentials "%s"' , implode ( ', ' , array_keys ( $ credentials ) ) ) ) ; }
Creates token from credentials via user providers

@param array $credentials

@return $this
@throws AuthenticationException
Creates token from credentials via user providers