<commit_before><?php
/**
 * Created by PhpStorm.
 * User: daniel
 * Date: 08.09.14
 * Time: 16:14
 */

namespace Cundd\PersistentObjectStore\Configuration;

/**
 * Class to read the configuration from config files
 *
 * @package Cundd\PersistentObjectStore\Configuration
 */
class ConfigurationReader {
	/**
	 * Reads the configuration from the configuration files
	 *
	 * @return array
	 */
	public function readConfigurationFiles() {
		$configuration = array_merge_recursive(
			$this->readConfigurationFile('/etc/pos')
		);
		if (isset($_SERVER['HOME']) && $_SERVER['HOME']) {
			$configuration = array_merge_recursive($configuration, $this->readConfigurationFile($_SERVER['HOME'] . '/.pos/config.json'));
		}
		$configuration = array_merge_recursive($configuration, $this->readConfigurationFile('.pos-config.json'));
		return $configuration;
	}

	/**
	 * Tries to read the given configuration file
	 *
	 * @param string $file
	 * @return array
	 */
	public function readConfigurationFile($file) {
		$configuration = array();
		if (file_exists($file) && is_readable($file)) {
			$configuration = json_decode(file_get_contents($file), TRUE);
		}
		return $configuration ? $configuration : array();
	}
} <commit_msg>Use $_ENV instead of $_SERVER<commit_after><?php
/**
 * Created by PhpStorm.
 * User: daniel
 * Date: 08.09.14
 * Time: 16:14
 */

namespace Cundd\PersistentObjectStore\Configuration;

/**
 * Class to read the configuration from config files
 *
 * @package Cundd\PersistentObjectStore\Configuration
 */
class ConfigurationReader {
	/**
	 * Reads the configuration from the configuration files
	 *
	 * @return array
	 */
	public function readConfigurationFiles() {
		$configuration = array_merge_recursive(
			$this->readConfigurationFile('/etc/pos')
		);
		if (isset($_ENV['HOME']) && $_ENV['HOME']) {
			$configuration = array_merge_recursive($configuration, $this->readConfigurationFile($_ENV['HOME'] . '/.pos/config.json'));
		}
		$configuration = array_merge_recursive($configuration, $this->readConfigurationFile('.pos-config.json'));
		return $configuration;
	}

	/**
	 * Tries to read the given configuration file
	 *
	 * @param string $file
	 * @return array
	 */
	public function readConfigurationFile($file) {
		$configuration = array();
		if (file_exists($file) && is_readable($file)) {
			$configuration = json_decode(file_get_contents($file), TRUE);
		}
		return $configuration ? $configuration : array();
	}
}
{'fraction_non_alphanumeric': 0.14426229508196722, 'fraction_numerical': 0.00819672131147541, 'mean_word_length': 4.650462962962963, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5619396', 'n_tokens_mistral': 773, 'n_tokens_neox': 700, 'n_words': 160}