<commit_before><?php

/**
 * Resmon PHP class
 * 
 * Can be used to generate Resmon parsable outputs. These outputs can be consumed
 * in Reconnoiter or other monitoring solutions.
 * 
 * See the Resmon project website for further info on the format:
 * https://labs.omniti.com/labs/resmon
 * 
 * @author <NAME> <<EMAIL>>
 *
 */
class Resmon {
	
	protected $module = 'main';
	protected $service = 'local';
	protected $data;
	
	const TYPE_STRING = 's';
	const TYPE_DEFAULT = '0';
	const TYPE_LONGINT = 'l';
	const TYPE_INT = 'i';
	const TYPE_UNSIGNED_LONGINT = 'L';
	const TYPE_UNSIGNED_INT = 'I';
	const TYPE_FLOAT = 'n';
	const STATE_OK = 'OK';
	const STATE_BAD = 'BAD';
	const STATE_WARNING = 'WARNING';
	
	/**
	 * @return the $module
	 */
	public function getModule() {
		return $this->module;
	}
	
	/**
	 * @return the $service
	 */
	public function getService() {
		return $this->service;
	}
	
	/**
	 * @param string $module
	 */
	public function setModule($module) {
		$this->module = $module;
	}
	
	/**
	 * @param string $service
	 */
	public function setService($service) {
		$this->service = $service;
	}
	
	/**
	 * Add new metric
	 * 
	 * @param string $name Unique name of the metric
	 * @param mixed $value The value of the metric
	 * @param string $type Metric type (best defined by the TYPE_* constants)
	 */
	public function addMetric($name, $value, $type = self::TYPE_DEFAULT) {
		$this->data [$this->getModule ()] [$this->getService ()] ['metrics'] [] = array (
			'name' => $name, 
			'value' => $value, 
			'type' => $type
		);
	}

	/**
	 * Set the state of currently used module/service
	 * 
	 * @param string $state State of the check, can be OK, BAD or WARNING
	 */
	public function setState($state = self::STATE_OK) {
		$this->data [$this->getModule ()] [$this->getService ()] ['state'] [] = $state;
	}

	/**
	 * Return the generated Resmon XML
	 * 
	 * @param boolean $print If set to true (default) print the XML with correct header
	 * @return string The generated XML
	 */
	public function outputAsXML( $print = true ) {
		$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
		$output .= "<?xml-stylesheet type=\"text/xsl\" href=\"resmon.xsl\"?>\n";
		$output .= "<ResmonResults>\n";

		foreach ($this->data as $module => $services) {
			foreach ($services as $service => $serviceData) {
				$output .= sprintf("\t<ResmonResult module=\"%s\" service=\"%s\">\n", 
					htmlentities($module), htmlentities($service));
				$output .= sprintf("\t<last_update>%d</last_update>\n", time());
				
				foreach ($serviceData['metrics'] as $metric) {
					$output .= sprintf ( "\t\t<metric name=\"%s\" type=\"%s\">%s</metric>\n", 
						htmlentities($metric['name']), $metric['type'], htmlentities($metric['value']) );
				}
				$output .= sprintf("\t\t<state>%s</state>\n\t</ResmonResult>", 
					empty($serviceData['state'])?self::STATE_OK:$serviceData['state']);
			}
		}
		$output .= '</ResmonResults>';
		
		if ($print) {
			header ( "Content-Type: text/xml; encoding=UTF-8" );
			echo $output;
		}
		
		return $output;
	}
	
}
<commit_msg>Improved descriptions<commit_after><?php

/**
 * Resmon PHP base class
 * 
 * Can be used to generate Resmon parsable outputs. These outputs can be consumed
 * in Reconnoiter or other monitoring solutions.
 * 
 * See the Resmon project website for further info on the format:
 * https://labs.omniti.com/labs/resmon
 * 
 * @author <NAME> <<EMAIL>>
 * 
 */
class Resmon {
	
	protected $module = 'main';
	protected $service = 'local';
	protected $data;
	
	const TYPE_STRING = 's';
	const TYPE_DEFAULT = '0';
	const TYPE_LONGINT = 'l';
	const TYPE_INT = 'i';
	const TYPE_UNSIGNED_LONGINT = 'L';
	const TYPE_UNSIGNED_INT = 'I';
	const TYPE_FLOAT = 'n';
	const STATE_OK = 'OK';
	const STATE_BAD = 'BAD';
	const STATE_WARNING = 'WARNING';
	
	/**
	 * @return the $module
	 */
	public function getModule() {
		return $this->module;
	}
	
	/**
	 * @return the $service
	 */
	public function getService() {
		return $this->service;
	}
	
	/**
	 * Set currently used module name
	 * 
	 * @param string $module
	 */
	public function setModule($module) {
		$this->module = $module;
	}
	
	/**
	 * Set currently used service
	 * 
	 * @param string $service
	 */
	public function setService($service) {
		$this->service = $service;
	}
	
	/**
	 * Add new metric
	 * 
	 * @param string $name Unique name of the metric
	 * @param mixed $value The value of the metric
	 * @param string $type Metric type (best defined by the TYPE_* constants)
	 */
	public function addMetric($name, $value, $type = self::TYPE_DEFAULT) {
		$this->data [$this->getModule ()] [$this->getService ()] ['metrics'] [] = array (
			'name' => $name, 
			'value' => $value, 
			'type' => $type
		);
	}

	/**
	 * Set the state of currently used module/service
	 * 
	 * @param string $state State of the check, can be OK, BAD or WARNING
	 */
	public function setState($state = self::STATE_OK) {
		$this->data [$this->getModule ()] [$this->getService ()] ['state'] [] = $state;
	}

	/**
	 * Return the generated Resmon XML
	 * 
	 * @param boolean $print If set to true (default) print the XML with correct header
	 * @return string The generated XML
	 */
	public function outputAsXML( $print = true ) {
		$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
		$output .= "<?xml-stylesheet type=\"text/xsl\" href=\"resmon.xsl\"?>\n";
		$output .= "<ResmonResults>\n";

		foreach ($this->data as $module => $services) {
			foreach ($services as $service => $serviceData) {
				$output .= sprintf("\t<ResmonResult module=\"%s\" service=\"%s\">\n", 
					htmlentities($module), htmlentities($service));
				$output .= sprintf("\t<last_update>%d</last_update>\n", time());
				
				foreach ($serviceData['metrics'] as $metric) {
					$output .= sprintf ( "\t\t<metric name=\"%s\" type=\"%s\">%s</metric>\n", 
						htmlentities($metric['name']), $metric['type'], htmlentities($metric['value']) );
				}
				$output .= sprintf("\t\t<state>%s</state>\n\t</ResmonResult>", 
					empty($serviceData['state'])?self::STATE_OK:$serviceData['state']);
			}
		}
		$output .= '</ResmonResults>';
		
		if ($print) {
			header ( "Content-Type: text/xml; encoding=UTF-8" );
			echo $output;
		}
		
		return $output;
	}
	
} // Resmon
{'fraction_non_alphanumeric': 0.17968875340927323, 'fraction_numerical': 0.0016043638697256538, 'mean_word_length': 3.3901408450704227, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 2, '>': 65, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '1150738', 'n_tokens_mistral': 2275, 'n_tokens_neox': 2030, 'n_words': 554}