<commit_before><?php

namespace hidev\components;

use Yii;
use yii\helpers\ArrayHelper;

class Interpolator
{
    public function interpolate(&$data)
    {
        if (is_array($data)) {
            foreach ($data as &$item) {
                $this->interpolate($item);
            }
        } elseif (is_string($data)) {
            $data = preg_replace_callback('/\{{ (.*?) }}/', function ($matches) {
                return $this->get($matches[1]);
            }, $data);
        }
    }

    public function get($name)
    {
        list($scope, $subname) = explode('.', $name, 2);

        if ($scope === 'params') {
            return Yii::$app->params[$subname];
        } elseif ($scope === 'config') {
            return $this->getConfig($subname);
        } else {
            return $this->getConfig($name);
        }
    }

    public function getConfig($name)
    {
        list($goal, $subname) = explode('.', $name, 2);

        return ArrayHelper::getValue(Yii::$app->get('config')->getGoal($goal), $subname);
    }
}<commit_msg>changed Interpolator to substitute `$params[name]`<commit_after><?php

namespace hidev\components;

use Yii;
use yii\helpers\ArrayHelper;

class Interpolator
{
    public function interpolate(&$data)
    {
        if (is_array($data)) {
            foreach ($data as &$item) {
                $this->interpolate($item);
            }
        } elseif (is_string($data)) {
            $data = preg_replace_callback('/\\$(\\w+)\\[\'(.+?)\'\\]/', function ($matches) {
                return $this->get($matches[1], $matches[2]);
            }, $data);
        }
    }

    public function get($scope, $name)
    {
        if ($scope === 'params') {
            return Yii::$app->params[$name];
        } elseif ($scope === 'config') {
            return $this->getConfig($name);
        } else {
            return "\$${scope}['$name']";
        }
    }

    public function getConfig($name)
    {
        list($goal, $subname) = explode('.', $name, 2);

        return ArrayHelper::getValue(Yii::$app->get('config')->getGoal($goal), $subname);
    }
}
{'fraction_non_alphanumeric': 0.1875, 'fraction_numerical': 0.0028625954198473282, 'mean_word_length': 2.0657894736842106, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '7636503', 'n_tokens_mistral': 653, 'n_tokens_neox': 641, 'n_words': 121}