<commit_before><?php

/*
 * This file is part of the Vatsimphp package
 *
 * Copyright 2013 - <NAME> <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

namespace Vatsimphp;

use Vatsimphp\Sync\StatusSync;
use Vatsimphp\Sync\DataSync;

/**
 *
 * Main consumer class to retrieve and
 * query data from the VATSIM network
 *
 */
class VatsimData
{
    /**
     *
     * Default configuration
     * @var array
     */
    protected $config = array(
        'cacheDir' => '../Cache',
        'statusUrl' => '',
        'statusRefresh' => 86400,
        'dataRefresh' => 180,
        'dataExpire' => 3600,
        'forceRefresh' => false,
        'cacheOnly' => false,
    );

    /**
     *
     * Result iterator
     * @var \Vatsimphp\Result\ResultContainer
     */
    protected $results;

    /**
     *
     * Exception stack
     * @var array
     */
    protected $exceptionStack = array();

    /**
     *
     * Search for a callsign
     * @param string $callsign
     */
    public function searchCallsign($callsign)
    {
        return $this->search('clients', array('callsign' => $callsign));
    }

    /**
     *
     * Expose search on result container
     * @param string $objectType
     * @param array $query
     */
    public function search($objectType, $query)
    {
        return $this->results->search($objectType, $query);
    }

    /**
     *
     * Override default config settings
     * @param string $key
     * @param mixed(string|boolean|integer) $value
     */
    public function setConfig($key, $value)
    {
        if (isset($this->config[$key])) {
            $this->config[$key] = $value;
        }
    }

    /**
     *
     * Return config key
     * @param string $key
     * @return mixed(string|boolean|integer)
     */
    public function getConfig($key)
    {
        if (isset($this->config[$key])) {
            return $this->config[$key] = $value;
        }
    }

    /**
     *
     * Load data from Vatsim network
     * @return boolean
     */
    public function loadData()
    {
        $status = new StatusSync();
        $status->setDefaults();
        $status->cacheDir = $this->config['cacheDir'];
        $status->refreshInterval = $this->config['statusRefresh'];

        if (!empty($this->config['statusUrl'])) {
            $status->registerUrl($this->config['statusUrl'], true);
        }

        try {
            $data = new DataSync();
            $data->setDefaults();
            $data->cacheDir = $this->config['cacheDir'];
            $data->dataExpire = $this->config['dataExpire'];
            $data->refreshInterval = $this->config['dataRefresh'];
            $data->forceRefresh = $this->config['forceRefresh'];
            $data->cacheOnly = $this->config['cacheOnly'];
<commit_msg>Fix getOption<commit_after><?php

/*
 * This file is part of the Vatsimphp package
 *
 * Copyright 2013 - <NAME> <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

namespace Vatsimphp;

use Vatsimphp\Sync\StatusSync;
use Vatsimphp\Sync\DataSync;

/**
 *
 * Main consumer class to retrieve and
 * query data from the VATSIM network
 *
 */
class VatsimData
{
    /**
     *
     * Default configuration
     * @var array
     */
    protected $config = array(
        'cacheDir' => '../Cache',
        'statusUrl' => '',
        'statusRefresh' => 86400,
        'dataRefresh' => 180,
        'dataExpire' => 3600,
        'forceRefresh' => false,
        'cacheOnly' => false,
    );

    /**
     *
     * Result iterator
     * @var \Vatsimphp\Result\ResultContainer
     */
    protected $results;

    /**
     *
     * Exception stack
     * @var array
     */
    protected $exceptionStack = array();

    /**
     *
     * Search for a callsign
     * @param string $callsign
     */
    public function searchCallsign($callsign)
    {
        return $this->search('clients', array('callsign' => $callsign));
    }

    /**
     *
     * Expose search on result container
     * @param string $objectType
     * @param array $query
     */
    public function search($objectType, $query)
    {
        return $this->results->search($objectType, $query);
    }

    /**
     *
     * Override default config settings
     * @param string $key
     * @param mixed(string|boolean|integer) $value
     */
    public function setConfig($key, $value)
    {
        if (isset($this->config[$key])) {
            $this->config[$key] = $value;
        }
    }

    /**
     *
     * Return config key
     * @param string $key
     * @return mixed(string|boolean|integer)
     */
    public function getConfig($key)
    {
        if (isset($this->config[$key])) {
            return $this->config[$key];
        }
    }

    /**
     *
     * Load data from Vatsim network
     * @return boolean
     */
    public function loadData()
    {
        $status = new StatusSync();
        $status->setDefaults();
        $status->cacheDir = $this->config['cacheDir'];
        $status->refreshInterval = $this->config['statusRefresh'];

        if (!empty($this->config['statusUrl'])) {
            $status->registerUrl($this->config['statusUrl'], true);
        }

        try {
            $data = new DataSync();
            $data->setDefaults();
            $data->cacheDir = $this->config['cacheDir'];
            $data->dataExpire = $this->config['dataExpire'];
            $data->refreshInterval = $this->config['dataRefresh'];
            $data->forceRefresh = $this->config['forceRefresh'];
            $data->cacheOnly = $this->config['cacheOnly'];

{'fraction_non_alphanumeric': 0.1377838744093888, 'fraction_numerical': 0.006096631611034903, 'mean_word_length': 2.210371819960861, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5082050', 'n_tokens_mistral': 1905, 'n_tokens_neox': 1856, 'n_words': 494}