<commit_before><?php

/**
 * Base class for QuickBooks objects
 * 
 * Copyright (c) {2010-04-16} {<NAME> / ConsoliBYTE, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.opensource.org/licenses/eclipse-1.0.php
 * 
 * @author <NAME> <<EMAIL>>
 * @license LICENSE.txt
 * 
 * @package QuickBooks
 * @subpackage Object
 */

/**
 * QuickBooks XML stuff (we need this for some constants)
 */
QuickBooks_Loader::load('/QuickBooks/XML.php', false);

/**
 * QuickBooks XML parser class
 */
QuickBooks_Loader::load('/QuickBooks/XML/Parser.php');

/**
 * QuickBooks data type casting
 */
QuickBooks_Loader::load('/QuickBooks/Cast.php');

/**
 * Base class for QuickBooks objects
 */
abstract class QuickBooks_QBXML_Object
{
	/**
	 * QuickBooks XML parser option - preserve empty XML elements
	 */
	const XML_PRESERVE = QuickBooks_XML::XML_PRESERVE;
	
	/**
	 * QuickBooks XML parser option - drop empty XML elements
	 */
	const XML_DROP = QuickBooks_XML::XML_DROP;
	
	/**
	 * QuickBooks XML parser option - compress /> empty XML elements
	 */
	const XML_COMPRESS = QuickBooks_XML::XML_COMPRESS;

	/**
	 * Keys/values stored within the object
	 * 
	 * @var array
	 */
	protected $_object = array();
	
	/**
	 * Create a new instance of this QuickBooks class
	 * 
	 * @param array $arr
	 */
	public function __construct($arr)
	{
		$this->_object = $arr; 
	}
	
	/**
	 * Return a constant indicating the type of object
	 * 
	 * @return string
	 */
	abstract public function object();
		
	/**
	 * Get the date/time this object was created in QuickBooks
	 * 
	 * @param string $format		If you want the date/time in a particular format, specify the format here (use the notation from {@link http://www.php.net/date})
	 * @return string
	 */
	public function getTimeCreated($format = null)
	{
		if (!is_null($format))
		{
			return date($format, strtotime($this->get('TimeCreated')));
		}
		
		return $this->get('TimeCreated');
	}

	/** 
	 * Get the date/time when this object was last modified in QuickBooks
	 * 
	 * @param string $format		If you want the date/time in a particular format, specify the format here (use the notation from {@link http://www.php.net/date})
	 * @return string
	 */	
	public function getTimeModified($format = null)
	{
		if (!is_null($format))
		{
			return date($format, strtotime($this->get('TimeModified')));
		}
		
		return $this->get('TimeModified');
	}
	
	public function setEditSequence($value)
	{
		return $this->set('EditSequence', $value);
	}
	
	/**
	 * Get the QuickBooks EditSequence for this object
	 * 
	 * @return integer
	 */
	public function getEditSequence()
	{
		return $this->get('EditSequence');
	}
	
	/**
	 * Set a value within the object
	 * 
	 * @param string $key
	 * @param string $value
	 * @return boolean
	 */
	public function set($key, $value, $cast = true)
	{
		if (is_array($value))
		{
			$this->_object[$key] = $value;
		}
		else
		{
			//print('set(' . $key . ', ' . $value . ', ' . $cast . ')' . "\n");
			
			if ($cast)
			{
				$value = QuickBooks_Cast::cast($this->object(), $key, $value, true, false);
			}
			
			//print('	setting [' . $key . '] to value {' . $value . '}' . "\n");
			
			$this->_object[$key] = $value;
		}
		
		return true;<commit_msg>Bad hack for qbXML classes.<commit_after><?php

/**
 * Base class for QuickBooks objects
 * 
 * Copyright (c) {2010-04-16} {<NAME> / ConsoliBYTE, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.opensource.org/licenses/eclipse-1.0.php
 * 
 * @author <NAME> <<EMAIL>>
 * @license LICENSE.txt
 * 
 * @package QuickBooks
 * @subpackage Object
 */

/**
 * QuickBooks XML stuff (we need this for some constants)
 */
QuickBooks_Loader::load('/QuickBooks/XML.php', false);

/**
 * QuickBooks XML parser class
 */
QuickBooks_Loader::load('/QuickBooks/XML/Parser.php');

/**
 * QuickBooks data type casting
 */
QuickBooks_Loader::load('/QuickBooks/Cast.php');

/**
 * Base class for QuickBooks objects
 */
abstract class QuickBooks_QBXML_Object
{
	/**
	 * QuickBooks XML parser option - preserve empty XML elements
	 */
	const XML_PRESERVE = QuickBooks_XML::XML_PRESERVE;
	
	/**
	 * QuickBooks XML parser option - drop empty XML elements
	 */
	const XML_DROP = QuickBooks_XML::XML_DROP;
	
	/**
	 * QuickBooks XML parser option - compress /> empty XML elements
	 */
	const XML_COMPRESS = QuickBooks_XML::XML_COMPRESS;

	/**
	 * Keys/values stored within the object
	 * 
	 * @var array
	 */
	protected $_object = array();
	
	/**
	 * Create a new instance of this QuickBooks class
	 * 
	 * @param array $arr
	 */
	public function __construct($arr)
	{
		$this->_object = $arr; 
	}
	
	/**
	 * Return a constant indicating the type of object
	 * 
	 * @return string
	 */
	abstract public function object();
		
	/**
	 * Get the date/time this object was created in QuickBooks
	 * 
	 * @param string $format		If you want the date/time in a particular format, specify the format here (use the notation from {@link http://www.php.net/date})
	 * @return string
	 */
	public function getTimeCreated($format = null)
	{
		if (!is_null($format))
		{
			return date($format, strtotime($this->get('TimeCreated')));
		}
		
		return $this->get('TimeCreated');
	}

	/** 
	 * Get the date/time when this object was last modified in QuickBooks
	 * 
	 * @param string $format		If you want the date/time in a particular format, specify the format here (use the notation from {@link http://www.php.net/date})
	 * @return string
	 */	
	public function getTimeModified($format = null)
	{
		if (!is_null($format))
		{
			return date($format, strtotime($this->get('TimeModified')));
		}
		
		return $this->get('TimeModified');
	}
	
	public function setEditSequence($value)
	{
		return $this->set('EditSequence', $value);
	}
	
	/**
	 * Get the QuickBooks EditSequence for this object
	 * 
	 * @return integer
	 */
	public function getEditSequence()
	{
		return $this->get('EditSequence');
	}
	
	/**
	 * Set a value within the object
	 * 
	 * @param string $key
	 * @param string $value
	 * @return boolean
	 */
	public function set($key, $value, $cast = true)
	{
		if (is_array($value))
		{
			$this->_object[$key] = $value;
		}
		else
		{
			//print('set(' . $key . ', ' . $value . ', ' . $cast . ')' . "\n");
			
			if ($cast and $value != '__EMPTY__')
			{
				$value = QuickBooks_Cast::cast($this->object(), $key, $value, true, false);
			}
			
			//print('	setting [' . $key . '] to value {' . $value . '}' . "\n");
			
			$this->_object[$key] = $value;
		}
		
		return true;
{'fraction_non_alphanumeric': 0.14563679245283018, 'fraction_numerical': 0.003537735849056604, 'mean_word_length': 3.1882716049382718, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, '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': '1177695', 'n_tokens_mistral': 2385, 'n_tokens_neox': 2072, 'n_words': 630}