<commit_before><?php
/**
 * Milkyway Multimedia
 * Config.php
 *
 * @package milkywaymultimedia.com.au
 * @author <NAME> <<EMAIL>>
 */

namespace Milkyway\SS;

use Config as Original;

class Config {
    private static $_cache = [];

    /**
     * Get a config value from DataObject/YAML/environment vars using dot notation
     *
     * @param string $key
     * @param array $objects
     * @param mixed|null $default
     * @param Callable $parseEnvVarFn
     * @param array $beforeConfigNamespaceCheckCallbacks
     * @param bool $fromCache
     * @param bool $doCache
     * @return mixed|null
     */
    public static function get($key, $objects = [], $default = null, $parseEnvVarFn = null, $beforeConfigNamespaceCheckCallbacks = [], $fromCache = true, $doCache = true) {
	    foreach($objects as $object) {
		    if($object && ($object instanceof \ViewableData) && $object->$key)
			    return $object->$key;
	    }

	    // Grab mapping from object
	    $mapping = (array)Original::inst()->get('environment', 'mapping');

	    foreach($objects as $object) {
		    if($object && method_exists($object, 'config'))
		        $mapping = array_merge($mapping, (array)$object->config()->db_to_environment_mapping);
	    }

	    if(isset($mapping[$key]))
		    $key = $mapping[$key];

	    // 1. Check cache for valid key and return if found
        if($fromCache && isset(static::$_cache[$key])) {
            return static::$_cache[$key] === null ? $default : static::$_cache[$key];
        }<commit_msg>FIX: Objects so now load mapping in the correct order<commit_after><?php
/**
 * Milkyway Multimedia
 * Config.php
 *
 * @package milkywaymultimedia.com.au
 * @author <NAME> <<EMAIL>>
 */

namespace Milkyway\SS;

use Config as Original;

class Config {
    private static $_cache = [];

    /**
     * Get a config value from DataObject/YAML/environment vars using dot notation
     *
     * @param string $key
     * @param array $objects
     * @param mixed|null $default
     * @param Callable $parseEnvVarFn
     * @param array $beforeConfigNamespaceCheckCallbacks
     * @param bool $fromCache
     * @param bool $doCache
     * @return mixed|null
     */
    public static function get($key, $objects = [], $default = null, $parseEnvVarFn = null, $beforeConfigNamespaceCheckCallbacks = [], $fromCache = true, $doCache = true) {
	    foreach($objects as $object) {
		    if($object && ($object instanceof \ViewableData) && $object->$key)
			    return $object->$key;
	    }

	    // Grab mapping from object
	    $mapping = (array)Original::inst()->get('environment', 'mapping');
	    $objects = array_reverse($objects, true);

	    foreach($objects as $object) {
		    if($object && method_exists($object, 'config'))
		        $mapping = array_merge($mapping, (array)$object->config()->db_to_environment_mapping);
	    }

	    if(isset($mapping[$key]))
		    $key = $mapping[$key];

	    // 1. Check cache for valid key and return if found
        if($fromCache && isset(static::$_cache[$key])) {
            return static::$_cache[$key] === null ? $default : static::$_cache[$key];
        }
{'fraction_non_alphanumeric': 0.14805278403604763, 'fraction_numerical': 0.000643707756678468, 'mean_word_length': 3.1384820239680424, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, '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': '1148833', 'n_tokens_mistral': 944, 'n_tokens_neox': 888, 'n_words': 238}