<commit_before><?php
/**
 * Fuel PDF
 *
 * @package 	Fuel
 * @subpackage	Pdf
 * @version		1.1
 * @author 		<NAME> <<EMAIL>>
 * @license 	MIT License
 * @link 		https://github.com/indigo-soft
 */

namespace Pdf;

abstract class Pdf_Driver
{
	/**
	* Driver config
	*
	* @var array
	*/
	protected $config = array();

	/**
	 * Driver instance
	 *
	 * @var mixed
	 */
	protected $instance = null;

	/**
	* Driver constructor
	*
	* @param	array	$config	driver config
	*/
	public function __construct(array $config = array())
	{
		$this->config = $config;
	}

	/**
	* Get a driver config setting
	*
	* @param	string|null		$key		Config key
	* @param	mixed			$default	Default value
	* @return	mixed						Config setting value or the whole config array
	*/
	public function get_config($key = null, $default = null)
	{
		return is_null($key) ? $this->config : \Arr::get($this->config, $key, $default);
	}

	/**
	* Set a driver config setting
	*
	* @param	string|array	$key		Config key or array of key-value pairs
	* @param	mixed			$value		New config value
	* @return	$this						$this for chaining
	*/
	public function set_config($key, $value = null)
	{
		// Merge config or just set an element
		if (is_array($key))
		{
			// Set default values and merge config reverse order
			if ($value === true)
			{
				$this->config = \Arr::merge($key, $this->config);
			}
			else
			{
				$this->config = \Arr::merge($this->config, $key);
			}
		}
		else
		{
			\Arr::set($this->config, $key, $value);
		}

		return $this;
	}

	/**
	 * Initialize driver
	 *
	 * @return $this
	 */
	public function init()
	{
		$args = func_get_args();
		$this->instance = call_user_func_array(array($this, '_pdf'), $args);
		return $this;
	}

	/**
	 * Abstract function to load the driver
	 *
	 * @return mixed Driver instance
	 */
	abstract protected function _pdf();


	/**
	 * Magic functions catching non-existent functions/variables and passing them to the driver
	 */

	public function __call($method, $arguments)
	{
		if (method_exists($this->instance, $method))
		{
				$return = call_user_func_array(array($this->instance, $method), $arguments);
				return $return;
		}
		else
		{
			throw new \BadMethodCallException('Invalid method: '.get_called_class().'::'.$method);
		}
	}

	public function __get($name)
	{
		if (isset($this->{$name}))
		{
			return $this->{$name};
		}
		elseif(isset($this->instance->{$name}))
		{
			return $this->instance->{$name};
		}
		else
		{
			throw new \OutOfBoundsException('Undefined property: ' . get_called_class() . '::' . $name);
		}
	}

	public function __set($name, $value)
	{
		if (isset($this->{$name})) {
			$this->{$name} = $value;
		}
		else
		{
			$this->instance->{$name} = $value;
		}
	}
}<commit_msg>Coding standard<commit_after><?php
/**
 * Fuel PDF
 *
 * @package 	Fuel
 * @subpackage	Pdf
 * @version		1.1
 * @author 		<NAME> <<EMAIL>>
 * @license 	MIT License
 * @link 		https://github.com/indigo-soft
 */

namespace Pdf;

abstract class Pdf_Driver
{
	/**
	* Driver config
	*
	* @var array
	*/
	protected $config = array();

	/**
	 * Driver instance
	 *
	 * @var mixed
	 */
	protected $instance = null;

	/**
	* Driver constructor
	*
	* @param	array	$config	driver config
	*/
	public function __construct(array $config = array())
	{
		$this->config = $config;
	}

	/**
	* Get a driver config setting
	*
	* @param	string|null		$key		Config key
	* @param	mixed			$default	Default value
	* @return	mixed						Config setting value or the whole config array
	*/
	public function get_config($key = null, $default = null)
	{
		return is_null($key) ? $this->config : \Arr::get($this->config, $key, $default);
	}

	/**
	* Set a driver config setting
	*
	* @param	string|array	$key		Config key or array of key-value pairs
	* @param	mixed			$value		New config value
	* @return	$this						$this for chaining
	*/
	public function set_config($key, $value = null)
	{
		// Merge config or just set an element
		if (is_array($key))
		{
			// Set default values and merge config reverse order
			if ($value === true)
			{
				$this->config = \Arr::merge($key, $this->config);
			}
			else
			{
				$this->config = \Arr::merge($this->config, $key);
			}
		}
		else
		{
			\Arr::set($this->config, $key, $value);
		}

		return $this;
	}

	/**
	 * Initialize driver
	 *
	 * @return $this
	 */
	public function init()
	{
		$args = func_get_args();
		$this->instance = call_user_func_array(array($this, '_pdf'), $args);
		return $this;
	}

	/**
	 * Abstract function to load the driver
	 *
	 * @return mixed Driver instance
	 */
	abstract protected function _pdf();


	/**
	 * Magic functions catching non-existent functions/variables and passing them to the driver
	 */

	public function __call($method, $arguments)
	{
		if (method_exists($this->instance, $method))
		{
				$return = call_user_func_array(array($this->instance, $method), $arguments);
				return $return;
		}
		else
		{
			throw new \BadMethodCallException('Invalid method: '.get_called_class().'::'.$method);
		}
	}

	public function __get($name)
	{
		if (isset($this->{$name}))
		{
			return $this->{$name};
		}
		elseif(isset($this->instance->{$name}))
		{
			return $this->instance->{$name};
		}
		else
		{
			throw new \OutOfBoundsException('Undefined property: ' . get_called_class() . '::' . $name);
		}
	}

	public function __set($name, $value)
	{
		if (isset($this->{$name}))
		{
			$this->{$name} = $value;
		}
		else
		{
			$this->instance->{$name} = $value;
		}
	}
}
{'fraction_non_alphanumeric': 0.1641571795813441, 'fraction_numerical': 0.0007344840249724568, 'mean_word_length': 3.071001494768311, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 51, 'https://': 2, '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': '3911358', 'n_tokens_mistral': 2144, 'n_tokens_neox': 1915, 'n_words': 477}