<commit_before><?php
/**
 * @package api
 * @subpackage objects
 */
class KalturaDetachedResponseProfile extends KalturaBaseResponseProfile
{
	/**
	 * Friendly name
	 * 
	 * @var string
	 */
	public $name;
	
	/**
	 * @var KalturaResponseProfileType
	 */
	public $type;
	
	/**
	 * Comma separated fields list to be included or excluded
	 * 
	 * @var string
	 */
	public $fields;
	
	/**
	 * @var KalturaRelatedFilter
	 */
	public $filter;
	
	/**
	 * @var KalturaFilterPager
	 */
	public $pager;
	
	/**
	 * @var KalturaDetachedResponseProfileArray
	 */
	public $relatedProfiles;
	
	/**
	 * @var KalturaResponseProfileMappingArray
	 */
	public $mappings;
	
	private static $map_between_objects = array(
		'name', 
		'type',
		'fields',
		'pager',
		'relatedProfiles',
		'mappings',
	);
	
	/* (non-PHPdoc)
	 * @see KalturaObject::getMapBetweenObjects()
	 */
	public function getMapBetweenObjects()
	{
		return array_merge(parent::getMapBetweenObjects(), self::$map_between_objects);
	}
	
	/* (non-PHPdoc)
	 * @see KalturaObject::validateForUsage($sourceObject, $propertiesToSkip)
	 */
	public function validateForUsage($sourceObject, $propertiesToSkip = array())
	{
		$this->validatePropertyMinLength('name', 2, !is_null($sourceObject));
		
		// Allow null in case of update
		if(is_null($sourceObject))
		{
			$this->validatePropertyNotNull('type');
		}
		
		$this->validateNestedObjects();
	
		parent::validateForUsage($sourceObject, $propertiesToSkip);
	}
	
	public function validateNestedObjects($maxPageSize = null, $maxNestingLevel = null)
	{	
		$relatedProfiles = $this->relatedProfiles;
		if(!$relatedProfiles)
		{
			return;
		}
	
		if(is_null($maxPageSize))
		{
			$maxPageSize = kConf::get('response_profile_max_page_size', 'local', 100);
		}
		
		if(is_null($maxNestingLevel))
		{
			$maxNestingLevel = kConf::get('response_profile_max_nesting_level', 'local', 2);
		}
		
		if($maxNestingLevel > 0)
		{
			foreach($relatedProfiles as $relatedProfile)
			{
				/* @var $relatedProfile KalturaDetachedResponseProfile */
				$relatedProfile->validateNestedObjects($maxPageSize, $maxNestingLevel - 1);
				
				$pager = $relatedProfile->pager;
				if($pager)
				{
					$pager->validatePropertyMaxValue('pageSize', $maxPageSize, true);
				}
			}
		}
		elseif(count($relatedProfiles))
		{
			throw new KalturaAPIException(KalturaErrors::RESPONSE_PROFILE_MAX_NESTING_LEVEL);
		}
	}

	/* (non-PHPdoc)
	 * @see KalturaObject::fromObject($srcObj, $responseProfile)
	 */
	public function doFromObject($srcObj, KalturaDetachedResponseProfile $responseProfile = null)
	{
		/* @var $srcObj kResponseProfile */
		parent::doFromObject($srcObj, $responseProfile);
		
		if($srcObj->getFilter() && $this->shouldGet('filter', $responseProfile))
		{
			$filterApiClassName = $srcObj->getFilterApiClassName();
			$this->filter = new $filterApiClassName();
			$this->filter->fromObject($srcObj->getFilter());
		}
	}
	
	/* (non-PHPdoc)
	 * @see KalturaObject::toObject($object_to_fill, $props_to_skip)
	 */
	public function toObject($object = null, $propertiesToSkip = array())
	{
		if(!$object)
		{
			$object = new kResponseProfile();
		}
		
		if($this->filter)
		{
			$object->setFilterApiClassName(get_class($this->filter));
			$object->setFilter($this->filter->toObject());
		}
		
		return parent::toObject($object, $propertiesToSkip);
	}
	
	/**
	 * Return unique identifier to be used in cache
	 * @return string
	 */
	public function getKey()
	{
		if(!isset($this->uniq))
			$this->uniq = uniqid();
			
		$serial = serialize($this);
		KalturaLog::debug("Serial [{$this->uniq}]: $serial");
		
		return md5($serial);
	}
}<commit_msg>Key should be unique but not for every session<commit_after><?php
/**
 * @package api
 * @subpackage objects
 */
class KalturaDetachedResponseProfile extends KalturaBaseResponseProfile
{
	/**
	 * Friendly name
	 * 
	 * @var string
	 */
	public $name;
	
	/**
	 * @var KalturaResponseProfileType
	 */
	public $type;
	
	/**
	 * Comma separated fields list to be included or excluded
	 * 
	 * @var string
	 */
	public $fields;
	
	/**
	 * @var KalturaRelatedFilter
	 */
	public $filter;
	
	/**
	 * @var KalturaFilterPager
	 */
	public $pager;
	
	/**
	 * @var KalturaDetachedResponseProfileArray
	 */
	public $relatedProfiles;
	
	/**
	 * @var KalturaResponseProfileMappingArray
	 */
	public $mappings;
	
	private static $map_between_objects = array(
		'name', 
		'type',
		'fields',
		'pager',
		'relatedProfiles',
		'mappings',
	);
	
	/* (non-PHPdoc)
	 * @see KalturaObject::getMapBetweenObjects()
	 */
	public function getMapBetweenObjects()
	{
		return array_merge(parent::getMapBetweenObjects(), self::$map_between_objects);
	}
	
	/* (non-PHPdoc)
	 * @see KalturaObject::validateForUsage($sourceObject, $propertiesToSkip)
	 */
	public function validateForUsage($sourceObject, $propertiesToSkip = array())
	{
		$this->validatePropertyMinLength('name', 2, !is_null($sourceObject));
		
		// Allow null in case of update
		if(is_null($sourceObject))
		{
			$this->validatePropertyNotNull('type');
		}
		
		$this->validateNestedObjects();
	
		parent::validateForUsage($sourceObject, $propertiesToSkip);
	}
	
	public function validateNestedObjects($maxPageSize = null, $maxNestingLevel = null)
	{	
		$relatedProfiles = $this->relatedProfiles;
		if(!$relatedProfiles)
		{
			return;
		}
	
		if(is_null($maxPageSize))
		{
			$maxPageSize = kConf::get('response_profile_max_page_size', 'local', 100);
		}
		
		if(is_null($maxNestingLevel))
		{
			$maxNestingLevel = kConf::get('response_profile_max_nesting_level', 'local', 2);
		}
		
		if($maxNestingLevel > 0)
		{
			foreach($relatedProfiles as $relatedProfile)
			{
				/* @var $relatedProfile KalturaDetachedResponseProfile */
				$relatedProfile->validateNestedObjects($maxPageSize, $maxNestingLevel - 1);
				
				$pager = $relatedProfile->pager;
				if($pager)
				{
					$pager->validatePropertyMaxValue('pageSize', $maxPageSize, true);
				}
			}
		}
		elseif(count($relatedProfiles))
		{
			throw new KalturaAPIException(KalturaErrors::RESPONSE_PROFILE_MAX_NESTING_LEVEL);
		}
	}

	/* (non-PHPdoc)
	 * @see KalturaObject::fromObject($srcObj, $responseProfile)
	 */
	public function doFromObject($srcObj, KalturaDetachedResponseProfile $responseProfile = null)
	{
		/* @var $srcObj kResponseProfile */
		parent::doFromObject($srcObj, $responseProfile);
		
		if($srcObj->getFilter() && $this->shouldGet('filter', $responseProfile))
		{
			$filterApiClassName = $srcObj->getFilterApiClassName();
			$this->filter = new $filterApiClassName();
			$this->filter->fromObject($srcObj->getFilter());
		}
	}
	
	/* (non-PHPdoc)
	 * @see KalturaObject::toObject($object_to_fill, $props_to_skip)
	 */
	public function toObject($object = null, $propertiesToSkip = array())
	{
		if(!$object)
		{
			$object = new kResponseProfile();
		}
		
		if($this->filter)
		{
			$object->setFilterApiClassName(get_class($this->filter));
			$object->setFilter($this->filter->toObject());
		}
		
		return parent::toObject($object, $propertiesToSkip);
	}
	
	/**
	 * Return unique identifier to be used in cache
	 * @return string
	 */
	public function getKey()
	{
		return md5(serialize($this));
	}
}
{'fraction_non_alphanumeric': 0.14799775973116774, 'fraction_numerical': 0.0022402688322598714, 'mean_word_length': 4.213868613138686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '6440348', 'n_tokens_mistral': 2735, 'n_tokens_neox': 2338, 'n_words': 396}