<commit_before><?php

require_once(dirname(__FILE__) . '/../bootstrap/bootstrapServer.php');

/**
 * 
 * Represent all tests objects
 * Holds all the data from the data xml
 * @author Roni
 *
 */
class KalturaTestDataObject extends KalturaTestDataBase
{
	/**
	 * Creates a new Kaltura Object Identifier
	 * @param $keys
	 * @param $type
	 */
	function __construct($type = null, $additionalData = null, $dataObject = null)
	{
		$this->type = $type;
		$this->additionalData = $additionalData;
		$this->dataObject = $dataObject;
	}
	
	/**
	 * 
	 * Additional data for the object identifier (such as key, partnerId, secret, value)
	 * @var array<key => value>
	 */
	private $additionalData = array();
	
	/**
	 * 
	 * The data object to be retrieved like propel or kaltura object
	 * @var unknown_type
	 */
	private $dataObject = null;
	
	/**
	 * 
	 * Holds all the objects comments
	 * @var array<string> - key => value where key is the object field name and value is the value in the comment
	 */
	private $comments = array(); 
	
	/**
	 * (non-PHPdoc)
	 * @see KalturaTestDataBase::getValue()
	 */
	public function getValue()
	{
		$value = parent::getValue();
		
		if(is_null($value) || empty($value)) //If value property was not set
		{
			KalturaLog::debug("Value is null or empty\n");
			KalturaLog::debug("isKey = " . isset($this->additionalData['key']) . "\n");
			KalturaLog::debug("isValue = " . isset($this->additionalData['value']) . "\n");
			
			//We get the value from teh additional data
			if(isset($this->additionalData['key']))
			{
				$value = $this->additionalData['key'];					
			}
			elseif(isset($this->additionalData['value']))
			{
				$value = $this->additionalData['value'];					
			}
		}
		
		return $value;
	}
	
	/**
	 * @return the $additionalData
	 */
	public function getAdditionalData() {
		return $this->additionalData;
	}

	/**
	 * @return the $dataObject
	 */
	public function getDataObject() {
		return $this->dataObject;
	}

	/**
	 * @param array<key $additionalData
	 */
	public function setAdditionalData($additionalData) {
		$this->additionalData = $additionalData;
	}

	/**
	 * @param unknown_type $dataObject
	 */
	public function setDataObject($dataObject) {
		$this->dataObject = $dataObject;
	}

	/**
	 * 
	 * Adds a comment to the data object
	 * @param string $commentName
	 * @param string $commentValue
	 */
	public function addComment($commentName, $commentValue)
	{
		$this->comments[$commentName] = $commentValue;
	}
	
	/**
	 * @return the $comments
	 */
	public function getComments() {
		return $this->comments;
	}

	/**
	 * @param field_type $type
	 */
	public function setType($type) {
		$this->type = $type;
	}

	/**
	 * @param array<string> $comments
	 */
	public function setComments($comments) {
		$this->comments = $comments;
	}

	/**
	 * 
	 * Returns the object id 
	 */
	public function getId()
	{
		$objectId = null;
		
		if(isset($this->additionalData['key']))
		{
			$objectId = $this->additionalData['key'];
		}
		else if(isset($this->additionalData[$this->type . 'Id']))
		{
			$objectId = $this->additionalData[$this->type . 'Id'];
		}
		else if(isset($this->additionalData['Id']))
		{
			$objectId = $this->additionalData['Id'];
		}
		
		return $objectId;
	}
	
	/**
	 * 
	 * Returns the object type 
	 */
	public function getType()
	{
		return $this->type;
	}

	/**
	 * 
	 * Sets a given field by its name and given value
	 * @param string $field
	 * @param unknown_type $actualValue
	 * @throws Exception - if the object is not a propel object
	 */
	public function setByName($field, $value)
	{
		//If object is propel object
		if($this->dataObject instanceof BaseObject)
		{			
			$this->dataObject->setByName($field, $value);
		}
		elseif($this->dataObject instanceof KalturaObjectBase)
		{
			$this->dataObject->$field = $value; //Set the field as all fields are public in the API
		}
		else
			throw new Exception("Currentl only propel objects are supported");
	}

	/**
	 * The main function for converting to an Domdocument.
	 * Pass in a BaseObject (from kaltura) and returns that object serialized as a DomDocument<commit_msg>qnd: Added Support for obejtc inheriting KalturaObject<commit_after><?php

require_once(dirname(__FILE__) . '/../bootstrap/bootstrapServer.php');

/**
 * 
 * Represent all tests objects
 * Holds all the data from the data xml
 * @author Roni
 *
 */
class KalturaTestDataObject extends KalturaTestDataBase
{
	/**
	 * Creates a new Kaltura Object Identifier
	 * @param $keys
	 * @param $type
	 */
	function __construct($type = null, $additionalData = null, $dataObject = null)
	{
		$this->type = $type;
		$this->additionalData = $additionalData;
		$this->dataObject = $dataObject;
	}
	
	/**
	 * 
	 * Additional data for the object identifier (such as key, partnerId, secret, value)
	 * @var array<key => value>
	 */
	private $additionalData = array();
	
	/**
	 * 
	 * The data object to be retrieved like propel or kaltura object
	 * @var unknown_type
	 */
	private $dataObject = null;
	
	/**
	 * 
	 * Holds all the objects comments
	 * @var array<string> - key => value where key is the object field name and value is the value in the comment
	 */
	private $comments = array(); 
	
	/**
	 * (non-PHPdoc)
	 * @see KalturaTestDataBase::getValue()
	 */
	public function getValue()
	{
		$value = parent::getValue();
		
		if(is_null($value) || empty($value)) //If value property was not set
		{
			KalturaLog::debug("Value is null or empty\n");
			KalturaLog::debug("isKey = " . isset($this->additionalData['key']) . "\n");
			KalturaLog::debug("isValue = " . isset($this->additionalData['value']) . "\n");
			
			//We get the value from teh additional data
			if(isset($this->additionalData['key']))
			{
				$value = $this->additionalData['key'];					
			}
			elseif(isset($this->additionalData['value']))
			{
				$value = $this->additionalData['value'];					
			}
		}
		
		return $value;
	}
	
	/**
	 * @return the $additionalData
	 */
	public function getAdditionalData() {
		return $this->additionalData;
	}

	/**
	 * @return the $dataObject
	 */
	public function getDataObject() {
		return $this->dataObject;
	}

	/**
	 * @param array<key $additionalData
	 */
	public function setAdditionalData($additionalData) {
		$this->additionalData = $additionalData;
	}

	/**
	 * @param unknown_type $dataObject
	 */
	public function setDataObject($dataObject) {
		$this->dataObject = $dataObject;
	}

	/**
	 * 
	 * Adds a comment to the data object
	 * @param string $commentName
	 * @param string $commentValue
	 */
	public function addComment($commentName, $commentValue)
	{
		$this->comments[$commentName] = $commentValue;
	}
	
	/**
	 * @return the $comments
	 */
	public function getComments() {
		return $this->comments;
	}

	/**
	 * @param field_type $type
	 */
	public function setType($type) {
		$this->type = $type;
	}

	/**
	 * @param array<string> $comments
	 */
	public function setComments($comments) {
		$this->comments = $comments;
	}

	/**
	 * 
	 * Returns the object id 
	 */
	public function getId()
	{
		$objectId = null;
		
		if(isset($this->additionalData['key']))
		{
			$objectId = $this->additionalData['key'];
		}
		else if(isset($this->additionalData[$this->type . 'Id']))
		{
			$objectId = $this->additionalData[$this->type . 'Id'];
		}
		else if(isset($this->additionalData['Id']))
		{
			$objectId = $this->additionalData['Id'];
		}
		
		return $objectId;
	}
	
	/**
	 * 
	 * Returns the object type 
	 */
	public function getType()
	{
		return $this->type;
	}

	/**
	 * 
	 * Sets a given field by its name and given value
	 * @param string $field
	 * @param unknown_type $actualValue
	 * @throws Exception - if the object is not a propel object
	 */
	public function setByName($field, $value)
	{
		//If object is propel object
		if($this->dataObject instanceof BaseObject)
		{			
			$this->dataObject->setByName($field, $value);
		}
		elseif($this->dataObject instanceof KalturaObjectBase || $this->dataObject instanceof KalturaObject)
		{
			$this->dataObject->$field = $value; //Set the field as all fields are public in the API
		}
		else
			throw new Exception("Currentl only propel objects are supported");
	}

	/**
	 * The main function for converting to an Domdocument.
	 * Pass in a BaseObject (from kaltura) and returns that object serialized as a DomDocument
{'fraction_non_alphanumeric': 0.14718301363252503, 'fraction_numerical': 0.0, 'mean_word_length': 3.3403141361256545, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '232574', 'n_tokens_mistral': 2977, 'n_tokens_neox': 2565, 'n_words': 694}