<commit_before><?php
class XmlClientGenerator extends ClientGeneratorFromPhp  
{
    /**
     * @var DOMDocument
     */
    private $_doc = null;
    
    /**
     * @var DOMElement
     */
    private $_xmlElement = null;
    
    public function XmlClientGenerator()
    {
        parent::ClientGeneratorFromPhp();
        $this->_doc = new DOMDocument();
        $this->_doc->formatOutput = true; 
    }
    
	public function generate() 
	{
		$this->load();
		
	    $this->_xmlElement = $this->_doc->createElement("xml");
	    $this->_xmlElement->setAttribute('apiVersion', KALTURA_API_VERSION);
	    $this->_xmlElement->setAttribute('generatedDate', time());
	    $this->_doc->appendChild($this->_xmlElement);
	    
        $this->_xmlElement->appendChild(new DOMComment(" Generated on date " . strftime("%d/%m/%y %H:%M:%S" , time()) . " "));
        
	    $enumsElement = $this->_doc->createElement("enums");
        $classesElement = $this->_doc->createElement("classes");
        
		foreach($this->_types as $typeReflector)
		{
		    if ($typeReflector->isEnum() || $typeReflector->isStringEnum())
    		{
                $enumElement = $this->getEnumElement($typeReflector);
    			$enumsElement->appendChild($enumElement);
    		}
    		else if (!$typeReflector->isArray())
    		{
    			$classElement = $this->getClassElement($typeReflector);
    			$classesElement->appendChild($classElement);
		    }
		}		
		
		$servicesElement = $this->_doc->createElement("services");
		foreach($this->_services as $serviceReflector)
		{
			if(!isset($this->_includeList[strtolower($serviceReflector->getServiceId())]))
			{
				KalturaLog::debug("Service [" . $serviceReflector->getServiceName() . "] exluded");
				continue;
			}
				
		    $serviceIncludeList = $this->_includeList[strtolower($serviceReflector->getServiceId())];
		    $serviceElement = $this->_doc->createElement("service");
			$serviceElement->setAttribute("id", $serviceReflector->getServiceId());
			$serviceElement->setAttribute("name", $serviceReflector->getServiceName());
			$description = $serviceReflector->getServiceDescription();
		    $description = $this->fixDescription($description);
		    
			$serviceElement->setAttribute("description", $description);
			
			$actions = $serviceReflector->getActions();
			$actions = array_keys($actions);
			foreach($actions as $action)
			{
				if(!isset($serviceIncludeList[strtolower($action)]))
				{
					KalturaLog::debug("Action [" . $serviceReflector->getServiceName() . ".$action] exluded");
					continue;
				}
					
				$actionInfo = $serviceReflector->getActionInfo($action);
				
				if($actionInfo->deprecated || $actionInfo->serverOnly)
					continue;
					
				if (strpos($actionInfo->clientgenerator, "ignore") !== false)
					continue;
					
				$serviceActionElement = $this->getServiceActionElement($serviceReflector, $action);
				$serviceElement->appendChild($serviceActionElement);			
			}
			
			$servicesElement->appendChild($serviceElement);
		}
		
		$this->_xmlElement->appendChild($enumsElement);
		$this->_xmlElement->appendChild($classesElement);
		$this->_xmlElement->appendChild($servicesElement);
		
		$this->addFile("KalturaClient.xml", $this->_doc->saveXML());
	}
	
	private function getEnumElement(KalturaTypeReflector $typeReflector)
	{
	    $enumElement = $this->_doc->createElement("enum");
	    $enumElement->setAttribute("name", $typeReflector->getType()); 
    	if ($typeReflector->isEnum())
			$enumElement->setAttribute("enumType", "int");
		else if ($typeReflector->isStringEnum())
			$enumElement->setAttribute("enumType", "string");
			
		$contants = $typeReflector->getConstants();
		foreach($contants as $contant)
		{
			$name = $contant->getName();
			$value = $contant->getDefaultValue();
			$const = $this->_doc->createElement("const");
			$const->setAttribute("name", $name);
			$const->setAttribute("value", $value);
			
			$enumElement->appendChild($const);
		}
		
		return $enumElement;
	}
	
	private function getClassElement(KalturaTypeReflector $typeReflector)
	{
	    $properties = $typeReflector->getProperties();
    			
		$classElement = $this->_doc->createElement("class");
	    $classElement->setAttribute("name", $typeReflector->getType()); 

	    $parentTypeReflector = $typeReflector->getParentTypeReflector();
	    
	    if($typeReflector->isAbstract())
	    {
            $classElement->setAttribute("abstract", true);    
	    }
	    
	    if ($parentTypeReflector)
	    {
            $parentType = $parentTypeReflector->getType();
            $classElement->setAttribute("base", $parentType);    		        
	    }
	    
	    $properties = $typeReflector->getCurrentProperties();
		foreach($properties as $property)
		{
			$propType = $property->getType();
			$propName = $property->getName();
			
			$propertyElement = $this->_doc->createElement("property");
			$propertyElement->setAttribute("name", $propName);
			
			if ($property->isArray())
			{
			    $propertyElement->setAttribute("type", "array");
			    $propertyElement->setAttribute("arrayType", $property->getArrayType());
			}
			else if ($property->isEnum())
			{
			    $propertyElement->setAttribute("type", "int");
			    $propertyElement->setAttribute("enumType", $property->getType());
			}
			else if ($property->isStringEnum())
			{
			    $propertyElement->setAttribute("type", "string");
			    $propertyElement->setAttribute("enumType", $property->getType());
			}
			else
			{
			    $propertyElement->setAttribute("type", $propType);
			}
			
		    $propertyElement->setAttribute("readOnly", $property->isReadOnly() ? "1" : "0");
		    $propertyElement->setAttribute("insertOnly", $property->isInsertOnly() ? "1" : "0");<commit_msg>Added plugin attribute according to annotation<commit_after><?php
class XmlClientGenerator extends ClientGeneratorFromPhp  
{
    /**
     * @var DOMDocument
     */
    private $_doc = null;
    
    /**
     * @var DOMElement
     */
    private $_xmlElement = null;
    
    public function XmlClientGenerator()
    {
        parent::ClientGeneratorFromPhp();
        $this->_doc = new DOMDocument();
        $this->_doc->formatOutput = true; 
    }
    
	public function generate() 
	{
		$this->load();
		
	    $this->_xmlElement = $this->_doc->createElement("xml");
	    $this->_xmlElement->setAttribute('apiVersion', KALTURA_API_VERSION);
	    $this->_xmlElement->setAttribute('generatedDate', time());
	    $this->_doc->appendChild($this->_xmlElement);
	    
        $this->_xmlElement->appendChild(new DOMComment(" Generated on date " . strftime("%d/%m/%y %H:%M:%S" , time()) . " "));
        
	    $enumsElement = $this->_doc->createElement("enums");
        $classesElement = $this->_doc->createElement("classes");
        
		foreach($this->_types as $typeReflector)
		{
		    if ($typeReflector->isEnum() || $typeReflector->isStringEnum())
    		{
                $enumElement = $this->getEnumElement($typeReflector);
    			$enumsElement->appendChild($enumElement);
    		}
    		else if (!$typeReflector->isArray())
    		{
    			$classElement = $this->getClassElement($typeReflector);
    			$classesElement->appendChild($classElement);
		    }
		}		
		
		$servicesElement = $this->_doc->createElement("services");
		foreach($this->_services as $serviceReflector)
		{
			if(!isset($this->_includeList[strtolower($serviceReflector->getServiceId())]))
			{
				KalturaLog::debug("Service [" . $serviceReflector->getServiceName() . "] exluded");
				continue;
			}
				
		    $serviceIncludeList = $this->_includeList[strtolower($serviceReflector->getServiceId())];
		    $serviceElement = $this->_doc->createElement("service");
			$serviceElement->setAttribute("id", $serviceReflector->getServiceId());
			$serviceElement->setAttribute("name", $serviceReflector->getServiceName());
			$description = $serviceReflector->getServiceDescription();
		    $description = $this->fixDescription($description);
		    
			$serviceElement->setAttribute("description", $description);
		
			$package = $serviceReflector->getPackage();
			if(is_string($package))
			{
				$packages = explode('.', $package, 2);
				if(count($packages) == 2 && $packages[0] == 'plugins')
					$serviceElement->setAttribute("plugin", $packages[1]);
			}
		
			$actions = $serviceReflector->getActions();
			$actions = array_keys($actions);
			foreach($actions as $action)
			{
				if(!isset($serviceIncludeList[strtolower($action)]))
				{
					KalturaLog::debug("Action [" . $serviceReflector->getServiceName() . ".$action] exluded");
					continue;
				}
					
				$actionInfo = $serviceReflector->getActionInfo($action);
				
				if($actionInfo->deprecated || $actionInfo->serverOnly)
					continue;
					
				if (strpos($actionInfo->clientgenerator, "ignore") !== false)
					continue;
					
				$serviceActionElement = $this->getServiceActionElement($serviceReflector, $action);
				$serviceElement->appendChild($serviceActionElement);			
			}
			
			$servicesElement->appendChild($serviceElement);
		}
		
		$this->_xmlElement->appendChild($enumsElement);
		$this->_xmlElement->appendChild($classesElement);
		$this->_xmlElement->appendChild($servicesElement);
		
		$this->addFile("KalturaClient.xml", $this->_doc->saveXML());
	}
	
	private function getEnumElement(KalturaTypeReflector $typeReflector)
	{
	    $enumElement = $this->_doc->createElement("enum");
	    $enumElement->setAttribute("name", $typeReflector->getType());
    	if ($typeReflector->isEnum())
			$enumElement->setAttribute("enumType", "int");
		else if ($typeReflector->isStringEnum())
			$enumElement->setAttribute("enumType", "string");
			
		$package = $typeReflector->getPackage();
		if(is_string($package))
		{
			$packages = explode('.', $package, 2);
			if(count($packages) == 2 && $packages[0] == 'plugins')
				$enumElement->setAttribute("plugin", $packages[1]);
		}
		
		$contants = $typeReflector->getConstants();
		foreach($contants as $contant)
		{
			$name = $contant->getName();
			$value = $contant->getDefaultValue();
			$const = $this->_doc->createElement("const");
			$const->setAttribute("name", $name);
			$const->setAttribute("value", $value);
			
			$enumElement->appendChild($const);
		}
		
		return $enumElement;
	}
	
	private function getClassElement(KalturaTypeReflector $typeReflector)
	{
	    $properties = $typeReflector->getProperties();
    			
		$classElement = $this->_doc->createElement("class");
	    $classElement->setAttribute("name", $typeReflector->getType()); 

	    $parentTypeReflector = $typeReflector->getParentTypeReflector();
	    
	    if($typeReflector->isAbstract())
	    {
            $classElement->setAttribute("abstract", true);    
	    }
	    
	    if ($parentTypeReflector)
	    {
            $parentType = $parentTypeReflector->getType();
            $classElement->setAttribute("base", $parentType);    		        
	    }
	    
		$package = $typeReflector->getPackage();
		if(is_string($package))
		{
			$packages = explode('.', $package, 2);
			if(count($packages) == 2 && $packages[0] == 'plugins')
				$classElement->setAttribute("plugin", $packages[1]);
		}
		
	    $properties = $typeReflector->getCurrentProperties();
		foreach($properties as $property)
		{
			$propType = $property->getType();
			$propName = $property->getName();
			
			$propertyElement = $this->_doc->createElement("property");
			$propertyElement->setAttribute("name", $propName);
			
			if ($property->isArray())
			{
			    $propertyElement->setAttribute("type", "array");
			    $propertyElement->setAttribute("arrayType", $property->getArrayType());
			}
			else if ($property->isEnum())
			{
			    $propertyElement->setAttribute("type", "int");
			    $propertyElement->setAttribute("enumType", $property->getType());
			}
			else if ($property->isStringEnum())
			{
			    $propertyElement->setAttribute("type", "string");
			    $propertyElement->setAttribute("enumType", $property->getType());
			}
			else
			{
			    $propertyElement->setAttribute("type", $propType);
			}
			
		    $propertyElement->setAttribute("readOnly", $property->isReadOnly() ? "1" : "0");
		    $propertyElement->setAttribute("insertOnly", $property->isInsertOnly() ? "1" : "0");
{'fraction_non_alphanumeric': 0.17090221235298955, 'fraction_numerical': 0.0016448721111933548, 'mean_word_length': 3.774244208873184, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 233, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 22}, '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': '4531764', 'n_tokens_mistral': 4035, 'n_tokens_neox': 3567, 'n_words': 481}