<commit_before><?php

/**
 * Zend Library Extension
 *
 * PHP version 5
 *
 * @category Zle
 * @package  Zle_Controller
 * @author   <NAME> <<EMAIL>>
 * @license  http://framework.zend.com/license/new-bsd New BSD License
 * @link     http://framework.zend.com/
 */

/**
 * Zle_Controller_Action_Helper_UserAbstract
 *
 * @category Zle
 * @package  Zle_Controller
 * @author   <NAME> <<EMAIL>>
 * @license  http://framework.zend.com/license/new-bsd New BSD License
 * @link     http://framework.zend.com/
 */
abstract class Zle_Controller_Action_Helper_UserAbstract
    extends Zend_Controller_Action_Helper_Abstract
{
    /**
     * Auth instance
     * @var Zend_Auth
     */
    protected $_auth;

    /**
     * Initialize namespace for auth
     */
    public function __construct()
    {
        $this->_auth = Zend_Auth::getInstance();
        $r = new ReflectionClass($this);
        $this->_auth->setStorage(
            new Zend_Auth_Storage_Session('Zend_Auth_' . $r->getName())
        );
    }

    /**
     * Return current identity or null if user is not found
     *
     * @return mixed an user instance or null if not set
     */
    public function getUser()
    {
        return $this->_auth->getIdentity();
    }

    /**
     * Return current identity or null if user is not found
     *
     * @return mixed an user instance or null if not set
     */
    public function direct()
    {
        return $this->getUser();
    }

    /**
     * Return true iff an user is logged
     *
     * @return bool
     */
    public function isLogged()
    {
        return $this->_auth->hasIdentity();
    }

    /**
     * Store the session id in a persistent way for $days days
     *
     * @param int $days how many days for remember authentication
     */
    public function rememberAuth($days = 60)
    {
        Zend_Session::rememberMe($days * 86400);
    }

    /**
     * Perform an authentication attempt, return true if the user is
     * logged or an array of message in case of errors
     *
     * @param array $values values provided for authentication
     *
     * @return bool|array
     */
    public function login(array $values)
    {
        $adapter = $this->getAdapter();
        if (method_exists($adapter, 'setAuthenticationParameters')) {
            $adapter->setAuthenticationParameters($values);
        }
        // try to authenticate
        $result = $this->_auth->authenticate($adapter);
        // switch result
        return $result->getCode() === Zend_Auth_Result::SUCCESS
                ? true : $result->getMessages();
    }

    /**
     * Return the adapter used for authentication
     *
     * @return Zend_Auth_Adapter_Interface
     */
    abstract protected function getAdapter();

    /**
     * Logout current user
     */
    public function logout()
    {
        $this->_auth->clearIdentity();
        Zend_Session::forgetMe();
    }
}<commit_msg>Corretti warning checkstyle<commit_after><?php

/**
 * Zend Library Extension
 *
 * PHP version 5
 *
 * @category Zle
 * @package  Zle_Controller
 * @author   <NAME> <<EMAIL>>
 * @license  http://framework.zend.com/license/new-bsd New BSD License
 * @link     http://framework.zend.com/
 */

/**
 * Zle_Controller_Action_Helper_UserAbstract
 *
 * @category Zle
 * @package  Zle_Controller
 * @author   <NAME> <<EMAIL>>
 * @license  http://framework.zend.com/license/new-bsd New BSD License
 * @link     http://framework.zend.com/
 */
abstract class Zle_Controller_Action_Helper_UserAbstract
    extends Zend_Controller_Action_Helper_Abstract
{
    /**
     * Auth instance
     * @var Zend_Auth
     */
    private $_auth;

    /**
     * Initialize namespace for auth
     */
    public function __construct()
    {
        $this->_auth = Zend_Auth::getInstance();
        $r = new ReflectionClass($this);
        $this->_auth->setStorage(
            new Zend_Auth_Storage_Session('Zend_Auth_' . $r->getName())
        );
    }

    /**
     * Return current identity or null if user is not found
     *
     * @return mixed an user instance or null if not set
     */
    public function getUser()
    {
        return $this->_auth->getIdentity();
    }

    /**
     * Return current identity or null if user is not found
     *
     * @return mixed an user instance or null if not set
     */
    public function direct()
    {
        return $this->getUser();
    }

    /**
     * Return true iff an user is logged
     *
     * @return bool
     */
    public function isLogged()
    {
        return $this->_auth->hasIdentity();
    }

    /**
     * Store the session id in a persistent way for $days days
     *
     * @param int $days how many days for remember authentication
     *
     * @return void
     */
    public function rememberAuth($days = 60)
    {
        Zend_Session::rememberMe($days * 86400);
    }

    /**
     * Perform an authentication attempt, return true if the user is
     * logged or an array of message in case of errors
     *
     * @param array $values values provided for authentication
     *
     * @return bool|array
     */
    public function login(array $values)
    {
        $adapter = $this->getAdapter();
        if (method_exists($adapter, 'setAuthenticationParameters')) {
            $adapter->setAuthenticationParameters($values);
        }
        // try to authenticate
        $result = $this->_auth->authenticate($adapter);
        // switch result
        return $result->getCode() === Zend_Auth_Result::SUCCESS
                ? true : $result->getMessages();
    }

    /**
     * Return the adapter used for authentication
     *
     * @return Zend_Auth_Adapter_Interface
     */
    abstract protected function getAdapter();

    /**
     * Logout current user
     *
     * @return void
     */
    public function logout()
    {
        $this->_auth->clearIdentity();
        Zend_Session::forgetMe();
    }
}
{'fraction_non_alphanumeric': 0.11465400271370421, 'fraction_numerical': 0.0027137042062415195, 'mean_word_length': 2.1962059620596204, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5522269', 'n_tokens_mistral': 1702, 'n_tokens_neox': 1648, 'n_words': 454}