<commit_before><?php

namespace ASPEN;

class Config {
    private static $data;

    public static function load($file) {
        $contents = file_get_contents($file);
        if (!$contents) {
            throw new Exception("Failed to load configuration because the file cannot be found or opened.");
        }

        self::$data = json_decode($contents, true);
        return true;
    }<commit_msg>moved the cross-origin code to a function<commit_after><?php

namespace ASPEN;

class Config {
    private static $data;

    public static function getOriginInformation() {
        $origin             = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
        $requestMethod      = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
        $acRequestMethod    = isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']) ? $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'] : '';
        $acRequestHeaders   = isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']) ? $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'] : '';

        return ['origin'        => $origin,
            'requestMethod'     => $requestMethod,
            'acRequestMethod'   => $acRequestMethod,
            'acRequestHeaders'  => $acRequestHeaders];
    }

    public static function checkOrigin(array $info = []) {
        header('Access-Control-Allow-Origin: '.$info['origin']);
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Max-Age: 86400');

        if ($info['requestMethod'] == 'OPTIONS') {
            if ($info['acRequestMethod'] != '') header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
            if ($info['acRequestHeaders'] != '') header('Access-Control-Allow-Headers: '.$info['acRequestHeaders']);
            exit(0);
        }
    }

    public static function load($file) {
        $contents = file_get_contents($file);
        if (!$contents) {
            throw new Exception('Failed to load configuration because the file cannot be found or opened.');
        }

        self::$data = json_decode($contents, true);
        return true;
    }
{'fraction_non_alphanumeric': 0.13968853232656914, 'fraction_numerical': 0.002831524303916942, 'mean_word_length': 2.955223880597015, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '712208', 'n_tokens_mistral': 572, 'n_tokens_neox': 566, 'n_words': 128}