<commit_before><?php

class ApiResponder {

    // properties
    private $isTest;               // whether this invocation is for testing

    // functions which allow access by unauthenticated users
    // For now, all game functionality should require login: only
    // add things to this list if they are necessary for user
    // creation and/or login.
    private $unauthFunctions = array(
        'createUser',
        'verifyUser',
        'loadPlayerName',
        'login',
    );

    // constructor
    // * For live invocation:
    //   * start a session (and require api_core to get session functions)
    // * For test invocation:
    //   * don't start a session
    public function __construct($isTest = FALSE) {
        $this->isTest = $isTest;

        if (!($this->isTest)) {
            session_start();
            require_once 'api_core.php';
            require_once('../lib/bootstrap.php');
        }
    }

    // This function looks at the provided arguments and verifies
    // both that an appropriate interface routine exists and that
    // the requester has sufficient credentials to access it
    protected function verify_function_access($args) {
        if (array_key_exists('type', $args)) {
            $funcname = 'get_interface_response_' . $args['type'];
            if (method_exists($this, $funcname)) {
                if (in_array($args['type'], $this->unauthFunctions)) {
                    $result = array(
                        'ok' => TRUE,
                        'functype' => 'newuser',
                        'funcname' => $funcname,
                    );
                } else if (auth_session_exists()) {
                    $result = array(
                        'ok' => TRUE,
                        'functype' => 'auth',
                        'funcname' => $funcname,
                    );
                } else {
                    $result = array(<commit_msg>* checkstyle<commit_after><?php

class ApiResponder {

    // properties
    private $isTest;               // whether this invocation is for testing

    // functions which allow access by unauthenticated users
    // For now, all game functionality should require login: only
    // add things to this list if they are necessary for user
    // creation and/or login.
    private $unauthFunctions = array(
        'createUser',
        'verifyUser',
        'loadPlayerName',
        'login',
    );

    // constructor
    // * For live invocation:
    //   * start a session (and require api_core to get session functions)
    // * For test invocation:
    //   * don't start a session
    public function __construct($isTest = FALSE) {
        $this->isTest = $isTest;

        if (!($this->isTest)) {
            session_start();
            require_once 'api_core.php';
            require_once('../lib/bootstrap.php');
        }
    }

    // This function looks at the provided arguments and verifies
    // both that an appropriate interface routine exists and that
    // the requester has sufficient credentials to access it
    protected function verify_function_access($args) {
        if (array_key_exists('type', $args)) {
            $funcname = 'get_interface_response_' . $args['type'];
            if (method_exists($this, $funcname)) {
                if (in_array($args['type'], $this->unauthFunctions)) {
                    $result = array(
                        'ok' => TRUE,
                        'functype' => 'newuser',
                        'funcname' => $funcname,
                    );
                } elseif (auth_session_exists()) {
                    $result = array(
                        'ok' => TRUE,
                        'functype' => 'auth',
                        'funcname' => $funcname,
                    );
                } else {
                    $result = array(
{'fraction_non_alphanumeric': 0.10803108808290156, 'fraction_numerical': 0.0, 'mean_word_length': 1.5791583166332666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '3186439', 'n_tokens_mistral': 992, 'n_tokens_neox': 943, 'n_words': 289}