<commit_before><?php namespace Ivmelo\SUAPClient;

use Goutte\Client;

/**
 * SUAPClient. Get data from SUAP.
 */
class SUAPClient
{
    private $username;
    private $password;
    private $client;
    private $crawler;
    private $matricula;
    private $endpoint = 'https://suap.ifrn.edu.br';
    private $aluno_endpoint = 'https://suap.ifrn.edu.br/edu/aluno/';
    private $responsavel_endpoint = 'https://suap.ifrn.edu.br/edu/acesso_responsavel/';
    private $is_access_code = false;

    /**
     * Construct function
     * @param string  $username       Matricula
     * @param string  $password       <PASSWORD>'s password
     * @param boolean $is_access_code Wheter use access code
     */
    function __construct($username = null, $password = null, $is_access_code = false)
    {
        if ($username && $password) {
            $this->username = $username;
            $this->password = $password;
            $this->is_access_code = $is_access_code;
        }

        // guzzle client
        $this->client = new Client();
    }

    /**
     * Sets the credetials for this instance
     * @param string $username       Matricula
     * @param string $password       User's password
     * @param boolean $is_access_code Wheter use access code
     */
    public function setCredentials($username, $password, $is_access_code) {
        $this->username = $username;
        $this->password = $password;
        $this->is_access_code = $is_access_code;
    }

    /**
     * Does login for both cases (password or access key)
     */
    public function doLogin() {
        if ($this->is_access_code)
            $this->doResponsavelLogin();
        else
            $this->doAlunoLogin();
    }

    /**
    *  Does login with ID and password
    **/
    public function doAlunoLogin() {
        // get csrf token
        $this->crawler = $this->client->request('GET', $this->endpoint);
        $token = $this->crawler->filter('input[name="csrfmiddlewaretoken"]');
        $token = $token->attr('value');

        // get form and submit
        $form = $this->crawler->selectButton('Acessar')->form();<commit_msg>Grammar: whether instead of wheter<commit_after><?php namespace Ivmelo\SUAPClient;

use Goutte\Client;

/**
 * SUAPClient. Get data from SUAP.
 */
class SUAPClient
{
    private $username;
    private $password;
    private $client;
    private $crawler;
    private $matricula;
    private $endpoint = 'https://suap.ifrn.edu.br';
    private $aluno_endpoint = 'https://suap.ifrn.edu.br/edu/aluno/';
    private $responsavel_endpoint = 'https://suap.ifrn.edu.br/edu/acesso_responsavel/';
    private $is_access_code = false;

    /**
     * Construct function
     * @param string  $username       Matricula
     * @param string  $password       <PASSWORD>
     * @param boolean $is_access_code Whether use access code
     */
    function __construct($username = null, $password = null, $is_access_code = false)
    {
        if ($username && $password) {
            $this->username = $username;
            $this->password = $password;
            $this->is_access_code = $is_access_code;
        }

        // guzzle client
        $this->client = new Client();
    }

    /**
     * Sets the credetials for this instance
     * @param string $username       Matricula
     * @param string $password       <PASSWORD>
     * @param boolean $is_access_code Whether use access code
     */
    public function setCredentials($username, $password, $is_access_code) {
        $this->username = $username;
        $this->password = $password;
        $this->is_access_code = $is_access_code;
    }

    /**
     * Does login for both cases (password or access key)
     */
    public function doLogin() {
        if ($this->is_access_code)
            $this->doResponsavelLogin();
        else
            $this->doAlunoLogin();
    }

    /**
    *  Does login with ID and password
    **/
    public function doAlunoLogin() {
        // get csrf token
        $this->crawler = $this->client->request('GET', $this->endpoint);
        $token = $this->crawler->filter('input[name="csrfmiddlewaretoken"]');
        $token = $token->attr('value');

        // get form and submit
        $form = $this->crawler->selectButton('Acessar')->form();
{'fraction_non_alphanumeric': 0.13228752048700537, 'fraction_numerical': 0.0, 'mean_word_length': 2.3824228028503565, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 46, 'https://': 6, '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': '804922', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1285, 'n_words': 297}