<commit_before><?php
/**
 * This file is part of the DreamFactory Rave(tm)
 *
 * DreamFactory Rave(tm) <http://github.com/dreamfactorysoftware/rave>
 * Copyright 2012-2014 DreamFactory Software, Inc. <<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 DreamFactory\Library\Utility;

class ArrayUtils
{
    /**
     * A recursive array_change_key_case lowercase function.
     *
     * @param array $input
     *
     * @return array
     */
    public static function array_key_lower( $input )
    {
        if ( !is_array( $input ) )
        {
            trigger_error( "Invalid input array '{$input}'", E_USER_NOTICE );
            exit;
        }
        $input = array_change_key_case( $input, CASE_LOWER );
        foreach ( $input as $key => $array )
        {
            if ( is_array( $array ) )
            {
                $input[$key] = static::array_key_lower( $array );
            }
        }

        return $input;
    }

    /**
     * @param $array
     *
     * @return bool
     */<commit_msg>updating ArrayUtils<commit_after><?php
/**
 * This file is part of the DreamFactory Rave(tm)
 *
 * DreamFactory Rave(tm) <http://github.com/dreamfactorysoftware/rave>
 * Copyright 2012-2014 DreamFactory Software, Inc. <<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 DreamFactory\Library\Utility;

class ArrayUtils
{
    /**
     * @param array|\ArrayObject $target            Target to grab $key from
     * @param string             $key               Index into target to retrieve
     * @param mixed              $defaultValue      Value returned if $key is not in $target
     * @param bool               $emptyStringIsNull If true, and the result is an empty string (''), NULL is returned
     *
     * @return mixed
     */
    public static function get( array $target, $key, $defaultValue = null, $emptyStringIsNull = false )
    {
        $_result = is_array( $target ) ? ( array_key_exists( $key, $target ) ? $target[$key] : $defaultValue ) : $defaultValue;

        return $emptyStringIsNull && '' === $_result ? null : $_result;
    }

    /**
     * @param array|\ArrayObject $target Target to set $key in
     * @param string             $key    Index into target to retrieve
     * @param mixed              $value  The value to set
     */
    public static function set( array & $target, $key, $value = null )
    {
        is_array( $target ) && $target[$key] = $value;
    }

    /**
     * @param array|\ArrayObject $target Target to set $key in
     * @param string             $key    Index into target to retrieve
     *
     * @return bool True if key existed and was removed
     */
    public static function remove( array & $target, $key )
    {
        if ( static::has( $target, $key ) )
        {
            unset( $target[$key] );

            return true;
        }

        return false;
    }

    /**
     * @param array|\ArrayObject $target Target to check
     * @param string             $key    Key to check
     *
     * @return bool
     */
    public static function has( array $target, $key )
    {
        return is_array( $target ) && array_key_exists( $key, $target );
    }
    /**
     * A recursive array_change_key_case lowercase function.
     *
     * @param array $input
     *
     * @return array
     */
    public static function array_key_lower( $input )
    {
        if ( !is_array( $input ) )
        {
            trigger_error( "Invalid input array '{$input}'", E_USER_NOTICE );
            exit;
        }
        $input = array_change_key_case( $input, CASE_LOWER );
        foreach ( $input as $key => $array )
        {
            if ( is_array( $array ) )
            {
                $input[$key] = static::array_key_lower( $array );
            }
        }

        return $input;
    }

    /**
     * @param $array
     *
     * @return bool
     */
{'fraction_non_alphanumeric': 0.1055532870559412, 'fraction_numerical': 0.004899959167006942, 'mean_word_length': 2.1323529411764706, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2836846', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1354, 'n_words': 467}