<commit_before><?php
/**
 * Vision PHP-Framework
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012-2013 <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 */
namespace Vision\DependencyInjection\Config;

use Vision\DependencyInjection\Definition;

/**
 * AbstractConfig
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class AbstractConfig
{
    protected $definitions = array();
    
    protected $parameters = array();
    
    public function addDefinition($alias, Definition $definition) 
    {           
        $class = $this->resolveParameter($definition->getClass());
        $definition->setClass($class);        
        if ($alias !== null) {
            $this->definitions[$this->resolveParameter($alias)] = $definition;
        } else {
            $this->definitions[$class] = $definition;
        }
        return $definition;
    }
    
    public function getDefinition($alias)
    {
        if (isset($this->definitions[$alias])) {
            return $this->definitions[$alias];
        }
        return null;
    }
    
    public function getDefinitions()
    {
        return $this->definitions;
    }
    
    public function addParameter($key, $value)
    {
        $this->parameters[$key] = $this->resolveParameter($value);
        return $this;
    }
    
    public function addParameters(array $parameters)
    {
        foreach ($parameters as $key => $value) {
            $this->addParameter($key, $value);
        }
        return $this;
    }
    
    public function getParameter($key)
    {
        if (isset($this->parameters[$key])) {
            return $this->parameters[$key];
        }
        return null;
    }
    
    public function getParameters()
    {
        return $this->parameters;
    }
    
    protected function resolveParameter($dependency)
    {
        $i = substr_count($dependency, '%');        
        if ($i % 2 === 0 && $i >= 2) {      
            $di = $this;
            $dependency = preg_replace_callback("#%([\w.-]+)%#", function($match) use (&$di) {
                return $di->getParameter($match[1]) !== null ? $di->getParameter($match[1]) : $match[1];
            }, $dependency);            
        }
        return $dependency;
    }    
}<commit_msg>Added "u" modifier ... finally<commit_after><?php
/**
 * Vision PHP-Framework
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012-2013 <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 */
namespace Vision\DependencyInjection\Config;

use Vision\DependencyInjection\Definition;

/**
 * AbstractConfig
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class AbstractConfig
{
    protected $definitions = array();
    
    protected $parameters = array();
    
    public function addDefinition($alias, Definition $definition) 
    {           
        $class = $this->resolveParameter($definition->getClass());
        $definition->setClass($class);        
        if ($alias !== null) {
            $this->definitions[$this->resolveParameter($alias)] = $definition;
        } else {
            $this->definitions[$class] = $definition;
        }
        return $definition;
    }
    
    public function getDefinition($alias)
    {
        if (isset($this->definitions[$alias])) {
            return $this->definitions[$alias];
        }
        return null;
    }
    
    public function getDefinitions()
    {
        return $this->definitions;
    }
    
    public function addParameter($key, $value)
    {
        $this->parameters[$key] = $this->resolveParameter($value);
        return $this;
    }
    
    public function addParameters(array $parameters)
    {
        foreach ($parameters as $key => $value) {
            $this->addParameter($key, $value);
        }
        return $this;
    }
    
    public function getParameter($key)
    {
        if (isset($this->parameters[$key])) {
            return $this->parameters[$key];
        }
        return null;
    }
    
    public function getParameters()
    {
        return $this->parameters;
    }
    
    protected function resolveParameter($dependency)
    {
        $i = substr_count($dependency, '%');        
        if ($i % 2 === 0 && $i >= 2) {      
            $di = $this;
            $dependency = preg_replace_callback("#%([\w.-]+)%#u", function($match) use (&$di) {
                return $di->getParameter($match[1]) !== null ? $di->getParameter($match[1]) : $match[1];
            }, $dependency);            
        }
        return $dependency;
    }    
}
{'fraction_non_alphanumeric': 0.15035429583702392, 'fraction_numerical': 0.006200177147918512, 'mean_word_length': 2.081173260572988, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 55, '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': '360936', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1242, 'n_words': 247}