<commit_before><?php
/**
 * Nooku Framework - http://www.nooku.org
 *
 * @copyright	Copyright (C) 2007 - 2013 <NAME> and Timble CVBA. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		git://git.assembla.com/nooku-framework.git for the canonical source repository
 */

namespace Nooku\Library;

/**
 * Database Parameterizable Behavior
 *
 * @author  <NAME> <http://nooku.assembla.com/profile/johanjanssens>
 * @package Nooku\Library\Database
 */
class DatabaseBehaviorParameterizable extends DatabaseBehaviorAbstract
{
    /**
     * The parameters
     *
     * @var ObjectConfigInterface
     */
    protected $_parameters;

    /**
     * Initializes the options for the object
     *
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param   ObjectConfig $config  An optional ObjectConfig object with configuration options
     * @return void
     */
    protected function _initialize(ObjectConfig $config)
    {
        $config->append(array(
            'row_mixin' => true,
        ));

        parent::_initialize($config);
    }

    /**
     * Get the parameters
     *
     * Requires an 'parameters' table column
     *
     * @return ObjectConfigInterface
     */
    public function getParameters()
    {
        if($this->hasProperty('parameters') && !isset($this->_parameters))
        {
            $filter = $this->getTable()->getColumn('parameters')->filter;
            $type   = $this->getObject('filter.factory')->createFilter($filter)->getIdentifier()->name;
            $data   = trim($this->getProperty('parameters'));


            //Create the parameters object
            if(empty($data)) {
                $config = $this->getObject('object.config.factory')->createFormat($type);
            } else {
                $config = $this->getObject('object.config.factory')->fromString($type, $data);
            }

            $this->_parameters = $config;
        }

        return $this->_parameters;
    }

    /**
     * Merge the parameters
     *
     * @param $value
     */
    public function setPropertyParameters($value)
    {
        if(!empty($value))
        {
            if(!is_string($value)) {
                $value = $this->getParameters()->add($value)->toString();
            }
        }<commit_msg>Use the filter name directly.<commit_after><?php
/**
 * Nooku Framework - http://www.nooku.org
 *
 * @copyright	Copyright (C) 2007 - 2013 <NAME> and Timble CVBA. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		git://git.assembla.com/nooku-framework.git for the canonical source repository
 */

namespace Nooku\Library;

/**
 * Database Parameterizable Behavior
 *
 * @author  <NAME> <http://nooku.assembla.com/profile/johanjanssens>
 * @package Nooku\Library\Database
 */
class DatabaseBehaviorParameterizable extends DatabaseBehaviorAbstract
{
    /**
     * The parameters
     *
     * @var ObjectConfigInterface
     */
    protected $_parameters;

    /**
     * Initializes the options for the object
     *
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param   ObjectConfig $config  An optional ObjectConfig object with configuration options
     * @return void
     */
    protected function _initialize(ObjectConfig $config)
    {
        $config->append(array(
            'row_mixin' => true,
        ));

        parent::_initialize($config);
    }

    /**
     * Get the parameters
     *
     * Requires an 'parameters' table column
     *
     * @return ObjectConfigInterface
     */
    public function getParameters()
    {
        if($this->hasProperty('parameters') && !isset($this->_parameters))
        {
            $type = (array) $this->getTable()->getColumn('parameters')->filter;
            $data = trim($this->getProperty('parameters'));

            //Create the parameters object
            if(empty($data)) {
                $config = $this->getObject('object.config.factory')->createFormat($type[0]);
            } else {
                $config = $this->getObject('object.config.factory')->fromString($type[0], $data);
            }

            $this->_parameters = $config;
        }

        return $this->_parameters;
    }

    /**
     * Merge the parameters
     *
     * @param $value
     */
    public function setPropertyParameters($value)
    {
        if(!empty($value))
        {
            if(!is_string($value)) {
                $value = $this->getParameters()->add($value)->toString();
            }
        }
{'fraction_non_alphanumeric': 0.13882250706061264, 'fraction_numerical': 0.004344992396263307, 'mean_word_length': 2.251412429378531, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '2970468', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1263, 'n_words': 263}