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

/**
 * Column Database Schema
 *
 * @author  <NAME> <https://github.com/johanjanssens>
 * @package Koowa\Library\Database
 */
class KDatabaseSchemaColumn extends KObject implements Serializable
{
	/**
	 * Column name
	 *
	 * @var string
	 */
	public $name;

	/**
	 * Column type
	 *
	 * @var	string
	 */
	public $type;

	/**
	 * Column length
	 *
	 * @var integer
	 */
	public $length;

	/**
	 * Column scope
	 *
	 * @var string
	 */
	public $scope;

	/**
	 * Column default value
	 *
	 * @var string
	 */
	public $default;

	/**
	 * Required column
	 *
	 * @var bool
	 */
	public $required = false;

	/**
	 * Is the column a primary key
	 *
	 * @var bool
	 */
	public $primary = false;

	/**
	 * Is the column autoincremented
	 *
	 * @var	bool
	 */
	public $autoinc = false;

	/**
	 * Is the column unique
	 *
	 * @var	bool
	 */
	public $unique = false;

	/**
	 * Related index columns
	 *
	 * @var	bool
	 */
	public $related = array();

	/**
	 * Filter object
	 *
	 * Public access is allowed via __get() with $filter.
	 *
	 * @var	KFilterInterface
	 */
	protected $_filter;

	/**
     * Implements the virtual $filter property.
     *
     * The value can be a KFilter object, a filter name, an array of filter names or a filter identifier
     *
     * @param 	string  $key	The virtual property to set, only accepts 'filter'
     * @param 	string 	$value  Set the virtual property to this value.
     */
    public function __set($key, $value)
    {
        if ($key == 'filter') {
        	$this->_filter = $value;
        }
    }

    /**
     * Implements access to $_filter by reference so that it appears to be a public $filter property.
     *
     * @param   string  $key The virtual property to return, only accepts 'filter'
     * @return  mixed   The value of the virtual property.
     */
    public function __get($key)
    {
        if ($key == 'filter')
        {
           if(!isset($this->_filter)) {
                $this->_filter = $this->type;
            }

            if(!($this->_filter instanceof KFilterInterface)) {
                $this->_filter = $this->getObject('lib:filter.factory')->getFilter($this->_filter);
            }

            return $this->_filter;
        }

        return null;
    }

    public function serialize()
    {
        return KObjectManager::getInstance()->serializeObject($this);
    }

    public function unserialize($data)
    {
        KObjectManager::getInstance()->unserializeObject($this, $data);
    }
}<commit_msg>re #91: Serialize filter property too<commit_after><?php
/**
 * Koowa Framework - http://developer.joomlatools.com/koowa
 *
 * @copyright	Copyright (C) 2007 - 2013 <NAME> and Timble CVBA. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://github.com/joomlatools/koowa for the canonical source repository
 */

/**
 * Column Database Schema
 *
 * @author  <NAME> <https://github.com/johanjanssens>
 * @package Koowa\Library\Database
 */
class KDatabaseSchemaColumn extends KObject implements Serializable
{
	/**
	 * Column name
	 *
	 * @var string
	 */
	public $name;

	/**
	 * Column type
	 *
	 * @var	string
	 */
	public $type;

	/**
	 * Column length
	 *
	 * @var integer
	 */
	public $length;

	/**
	 * Column scope
	 *
	 * @var string
	 */
	public $scope;

	/**
	 * Column default value
	 *
	 * @var string
	 */
	public $default;

	/**
	 * Required column
	 *
	 * @var bool
	 */
	public $required = false;

	/**
	 * Is the column a primary key
	 *
	 * @var bool
	 */
	public $primary = false;

	/**
	 * Is the column autoincremented
	 *
	 * @var	bool
	 */
	public $autoinc = false;

	/**
	 * Is the column unique
	 *
	 * @var	bool
	 */
	public $unique = false;

	/**
	 * Related index columns
	 *
	 * @var	bool
	 */
	public $related = array();

	/**
	 * Filter object
	 *
	 * Public access is allowed via __get() with $filter.
	 *
	 * @var	KFilterInterface
	 */
	protected $_filter;

	/**
     * Implements the virtual $filter property.
     *
     * The value can be a KFilter object, a filter name, an array of filter names or a filter identifier
     *
     * @param 	string  $key	The virtual property to set, only accepts 'filter'
     * @param 	string 	$value  Set the virtual property to this value.
     */
    public function __set($key, $value)
    {
        if ($key == 'filter') {
        	$this->_filter = $value;
        }
    }

    /**
     * Implements access to $_filter by reference so that it appears to be a public $filter property.
     *
     * @param   string  $key The virtual property to return, only accepts 'filter'
     * @return  mixed   The value of the virtual property.
     */
    public function __get($key)
    {
        if ($key == 'filter')
        {
           if(!isset($this->_filter)) {
                $this->_filter = $this->type;
            }

            if(!($this->_filter instanceof KFilterInterface)) {
                $this->_filter = $this->getObject('lib:filter.factory')->getFilter($this->_filter);
            }

            return $this->_filter;
        }

        return null;
    }

    public function serialize()
    {
        $data = KObjectManager::getInstance()->serializeObject($this, true);
        $data['properties']['filter'] = (string)$this->filter->getIdentifier();

        return serialize($data);
    }

    public function unserialize($data)
    {
        KObjectManager::getInstance()->unserializeObject($this, $data);

        $data = unserialize($data);

        if (isset($data['properties']['filter'])) {
            $this->filter = $data['properties']['filter'];
        }
    }
}
{'fraction_non_alphanumeric': 0.13731443994601888, 'fraction_numerical': 0.0033738191632928477, 'mean_word_length': 2.255903349807798, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 38, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '3747079', 'n_tokens_mistral': 1913, 'n_tokens_neox': 1751, 'n_words': 506}