<commit_before><?php
/**
 * ArrayPath
 *
 * @link      http://github.com/mathiasgrimm/arraypath for the canonical source repository
 * @copyright Copyright (c) 2014 <NAME>. (http://github.com/mathiasgrimm)
 * @license   https://github.com/mathiasgrimm/arraypath/blob/master/LICENSE.txt Mathias Grimm License
 */
namespace Mathiasgrimm\Arraypath;

class ArrayPath
{
    /**
     * @var string
     */
    protected static $sSeparator = '/';

    /**
     * sets a new separator and returns the old one
     *
     * @param string $sSeparator
     * @return string
     */
    public static function setSeparator($sSeparator)
    {
        $sPrevSeparator   = static::$sSeparator;
        static::$sSeparator = $sSeparator;

        return $sPrevSeparator;
    }

    /**
     * returns the current separator
     *
     * @return string
     */
    public static function getSeparator()
    {
        return static::$sSeparator;
    }

    /**
     * gets the value of an index $mIndex from the array $aSource
     * in the format idx1/idx2/idx3/... where "/" is the current separator
     *
     * $mDefault is returned in case the requested index does not exists
     *
     * @param mixed $mIndex
     * @param array $aSource
     * @param mixed $mDefault
     * @return midex $mCurSource
     */
    public static function get($mIndex, $aSource, $mDefault = null)
    {
        $aPath      = explode(static::$sSeparator, $mIndex);
        $mPath      = '';
        $mCurSource = $aSource;
        $bExists    = true;

        foreach ($aPath as $mPath) {
            if (array_key_exists($mPath, (array) $mCurSource)) {
                $mCurSource  = $mCurSource[$mPath];
            } else {
                $bExists = false;
                break;
            }
        }

        if (!$bExists) {
            $mCurSource = $mDefault;
        }

        return $mCurSource;
    }

    /**
     * sets $mValue in the array $sSource for the given $mIndex key
     * where $mIndex is idx1/idx2/idx3/... and "/" is the current separator
     *<commit_msg>Fixing type declaration<commit_after><?php
/**
 * ArrayPath
 *
 * @link      http://github.com/mathiasgrimm/arraypath for the canonical source repository
 * @copyright Copyright (c) 2014 <NAME>. (http://github.com/mathiasgrimm)
 * @license   https://github.com/mathiasgrimm/arraypath/blob/master/LICENSE.txt Mathias Grimm License
 */
namespace Mathiasgrimm\Arraypath;

class ArrayPath
{
    /**
     * @var string
     */
    protected static $sSeparator = '/';

    /**
     * sets a new separator and returns the old one
     *
     * @param string $sSeparator
     * @return string
     */
    public static function setSeparator($sSeparator)
    {
        $sPrevSeparator   = static::$sSeparator;
        static::$sSeparator = $sSeparator;

        return $sPrevSeparator;
    }

    /**
     * returns the current separator
     *
     * @return string
     */
    public static function getSeparator()
    {
        return static::$sSeparator;
    }

    /**
     * gets the value of an index $mIndex from the array $aSource
     * in the format idx1/idx2/idx3/... where "/" is the current separator
     *
     * $mDefault is returned in case the requested index does not exists
     *
     * @param mixed $mIndex
     * @param array $aSource
     * @param mixed $mDefault
     * @return mixed $mCurSource
     */
    public static function get($mIndex, $aSource, $mDefault = null)
    {
        $aPath      = explode(static::$sSeparator, $mIndex);
        $mPath      = '';
        $mCurSource = $aSource;
        $bExists    = true;

        foreach ($aPath as $mPath) {
            if (array_key_exists($mPath, (array) $mCurSource)) {
                $mCurSource  = $mCurSource[$mPath];
            } else {
                $bExists = false;
                break;
            }
        }

        if (!$bExists) {
            $mCurSource = $mDefault;
        }

        return $mCurSource;
    }

    /**
     * sets $mValue in the array $sSource for the given $mIndex key
     * where $mIndex is idx1/idx2/idx3/... and "/" is the current separator
     *
{'fraction_non_alphanumeric': 0.11499272197962154, 'fraction_numerical': 0.0048520135856380394, 'mean_word_length': 1.9726027397260273, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '575671', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1235, 'n_words': 328}