<commit_before><?php defined('SYSPATH') or die('No direct script access.');
/**
 * Dataflow Output Abstract
 * 
 * @package		Dataflow
 * @category	Base
 * @author		<NAME> <<EMAIL>>
 * @copyright	(c) 2011 <NAME>
 * @license		MIT
 */
abstract class Kohana_Dataflow_Output 
{	
	/**
	 * Default driver
	 * 
	 * @static
	 * @access	public
	 * @var		string
	 */
	public static $default = 'json';
	
	/**
	 * Factory pattern
	 * 
	 * @static
	 * @access	public
	 * @return	Dataflow_Output
	 */
	public static function factory(array $config = array())
	{
		$config['driver'] = (isset($config['driver'])) ? $config['driver'] : self::$default;
		
		$class = 'Dataflow_Output_' . ucfirst(strtolower($config['driver']));
		
		return new $class($config);
	}
	
	/**
	 * Data array
	 * 
	 * @access	protected
	 * @var		array|string
	 */
	protected $_data = array();
	
	/**
	 * Cache driver type
	 * 
	 * @access	protected
	 * @var		string
	 */
	protected $_type;
	
	/**
	 * Initialize
	 * 
	 * @access	public
	 * @return	void
	 */
	public function __construct(array $config)
	{
		$this->_config = $config;
		
		$this->_type = $config['driver'];
	}
	
	/**
	 * Abstract content type for headers
	 * 
	 * @access	public
	 * @return	string
	 */
	abstract public function get_content_type();	
	
	/**
	 * Transform array to driver format. Return value.
	 * 
	 * @access	public
	 * @param	array
	 * @return	string
	 */
	abstract protected function _transform(array $data);
	
	/**
	 * Get method. Internal caching of transformed array.
	 * 
	 * @access	public
	 * @return	string
	 */
	public function & get()
	{
		if (is_array($this->_data))
		{
			$this->_data = $this->_transform($this->_data);
		}
		
		return $this->_data;
	}
	
	/**
	 * Set data array
	 * 
	 * @access	public
	 * @return	array
	 */
	public function set(array $data)
	{
		$this->_data = $data;
		
		return $this;
	}
	
	/**
	 * Magic method for converting object to string
	 * 
	 * @access	public<commit_msg>Added Dataflow_Output::as_array as an alternative to Dataflow_Output::get<commit_after><?php defined('SYSPATH') or die('No direct script access.');
/**
 * Dataflow Output Abstract
 * 
 * @package		Dataflow
 * @category	Base
 * @author		<NAME> <<EMAIL>>
 * @copyright	(c) 2011 <NAME>
 * @license		MIT
 */
abstract class Kohana_Dataflow_Output 
{	
	/**
	 * Default driver
	 * 
	 * @static
	 * @access	public
	 * @var		string
	 */
	public static $default = 'json';
	
	/**
	 * Factory pattern
	 * 
	 * @static
	 * @access	public
	 * @return	Dataflow_Output
	 */
	public static function factory(array $config = array())
	{
		$config['driver'] = (isset($config['driver'])) ? $config['driver'] : self::$default;
		
		$class = 'Dataflow_Output_' . ucfirst(strtolower($config['driver']));
		
		return new $class($config);
	}
	
	/**
	 * Data array
	 * 
	 * @access	protected
	 * @var		array|string
	 */
	protected $_data = array();
	
	/**
	 * Cache driver type
	 * 
	 * @access	protected
	 * @var		string
	 */
	protected $_type;
	
	/**
	 * Initialize
	 * 
	 * @access	public
	 * @return	void
	 */
	public function __construct(array $config)
	{
		$this->_config = $config;
		
		$this->_type = $config['driver'];
	}
	
	/**
	 * Abstract content type for headers
	 * 
	 * @access	public
	 * @return	string
	 */
	abstract public function get_content_type();	
	
	/**
	 * Transform array to driver format. Return value.
	 * 
	 * @access	public
	 * @param	array
	 * @return	string
	 */
	abstract protected function _transform(array $data);
	
	/**
	 * Get method. Internal caching of transformed array.
	 * 
	 * @access	public
	 * @return	string
	 */
	public function & get()
	{
		if (is_array($this->_data))
		{
			$this->_data = $this->_transform($this->_data);
		}
		
		return $this->_data;
	}
	
	/**
	 * Set data array
	 * 
	 * @access	public
	 * @return	array
	 */
	public function set(array $data)
	{
		$this->_data = $data;
		
		return $this;
	}
	
	/**
	 * Alternative method call for get
	 * 
	 * @access	public
	 * @return	array
	 */
	public function as_array()
	{
		return $this->_get();
	}
	
	/**
	 * Magic method for converting object to string
	 * 
	 * @access	public
{'fraction_non_alphanumeric': 0.15094798249878463, 'fraction_numerical': 0.0019445794846864365, 'mean_word_length': 2.8493919550982225, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 28, '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': '6593428', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1302, 'n_words': 351}