<commit_before><?php

use XeroPHP\Application\PartnerApplication;
use XeroPHP\Remote\Request;
use XeroPHP\Remote\URL;

// Start a session for the oauth session storage
session_start();

//These are the minimum settings - for more options, refer to examples/config.php
$config = [
    'oauth' => [
        'callback' => 'http://localhost/',
        'consumer_key' => 'k',
        'consumer_secret' => 's',
        'rsa_private_key' => 'file://certs/privatekey.pem',
        'signature_location' => \XeroPHP\Remote\OAuth\Client::SIGN_LOCATION_QUERY
    ],
    'curl' => [
        CURLOPT_CAINFO => 'certs/ca-bundle.crt'
    ]
];

$xero = new PartnerApplication($config);

$oauth_session = getOAuthSession();

// If no session found
if ($oauth_session === null) {
    $url = new URL($xero, URL::OAUTH_REQUEST_TOKEN);

    $request = new Request($xero, $url);

    //Here's where you'll see if your keys are valid.
    //You can catch a BadRequestException.
    try {
        $request->send();
    } catch (Exception $e) {
        echo($e->getCode());
        print_r($request->getResponse()->getOAuthResponse());
    }

    $oauth_response = $request->getResponse()->getOAuthResponse();

    setOAuthSession(
        $oauth_response['oauth_token'],
        $oauth_response['oauth_token_secret']
    );

    printf('<a href="%s">Click here to Authorize</a>', $xero->getAuthorizeURL($oauth_response['oauth_token']));
    exit;
} elseif (isset($oauth_session['session_handle']) && !isset($oauth_session['expires'])) {
    // If session is expired refresh the token
    $url = new URL($xero, URL::OAUTH_ACCESS_TOKEN);<commit_msg>Code style: no_unneeded_control_parentheses<commit_after><?php

use XeroPHP\Application\PartnerApplication;
use XeroPHP\Remote\Request;
use XeroPHP\Remote\URL;

// Start a session for the oauth session storage
session_start();

//These are the minimum settings - for more options, refer to examples/config.php
$config = [
    'oauth' => [
        'callback' => 'http://localhost/',
        'consumer_key' => 'k',
        'consumer_secret' => 's',
        'rsa_private_key' => 'file://certs/privatekey.pem',
        'signature_location' => \XeroPHP\Remote\OAuth\Client::SIGN_LOCATION_QUERY
    ],
    'curl' => [
        CURLOPT_CAINFO => 'certs/ca-bundle.crt'
    ]
];

$xero = new PartnerApplication($config);

$oauth_session = getOAuthSession();

// If no session found
if ($oauth_session === null) {
    $url = new URL($xero, URL::OAUTH_REQUEST_TOKEN);

    $request = new Request($xero, $url);

    //Here's where you'll see if your keys are valid.
    //You can catch a BadRequestException.
    try {
        $request->send();
    } catch (Exception $e) {
        echo $e->getCode();
        print_r($request->getResponse()->getOAuthResponse());
    }

    $oauth_response = $request->getResponse()->getOAuthResponse();

    setOAuthSession(
        $oauth_response['oauth_token'],
        $oauth_response['oauth_token_secret']
    );

    printf('<a href="%s">Click here to Authorize</a>', $xero->getAuthorizeURL($oauth_response['oauth_token']));
    exit;
} elseif (isset($oauth_session['session_handle']) && !isset($oauth_session['expires'])) {
    // If session is expired refresh the token
    $url = new URL($xero, URL::OAUTH_ACCESS_TOKEN);
{'fraction_non_alphanumeric': 0.15795905896730827, 'fraction_numerical': 0.0, 'mean_word_length': 3.5346260387811634, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, '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': '4360748', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1065, 'n_words': 220}