<commit_before><?php

/**
 * A specific page within a {@link DocumentationEntity}.
 * Has to represent an actual file, please use {@link DocumentationViewer}
 * to generate "virtual" index views.
 * 
 * @package sapphiredocs
 */
class DocumentationPage extends ViewableData {
	
	/**
	 * @var DocumentationEntity
	 */
	protected $entity;
	
	/**
	 * @var String 
	 */
	protected $relativePath;
	
	/**
	 * @var String
	 */
	protected $lang = 'en';
	
	/**
	 * @var String
	 */
	protected $version;
	
	/**
	 * @return DocumentationEntity
	 */
	function getEntity() {
		return $this->entity;
	}
	
	function setEntity($entity) {
		$this->entity = $entity;
	}
		
	/**
	 * @return String Relative path to file or folder within the entity (including file extension),
	 * but excluding version or language folders.
	 */
	function getRelativePath() {
		return $this->relativePath;
	}
	
	function setRelativePath($path) {
		$this->relativePath = $path;
	}
	
	/**
	 * Absolute path including version and lang folder.
	 * 
	 *  @return String 
	 */
	function getPath() {
		$path = realpath(rtrim($this->entity->getPath($this->version, $this->lang), '/') . '/' . $this->getRelativePath());

		if(!file_exists($path)) {
			throw new InvalidArgumentException(sprintf(
				'Path could not be found. Module path: %s, file path: %s', 
				$this->entity->getPath(),
				$this->relativePath
			));
		}
		
		return $path;
	}
		
	function getLang() {
		return $this->lang;
	}
	
	function setLang($lang) {
		$this->lang = $lang;
	}
	
	function getVersion() {
		return $this->version;
	}
	
	function setVersion($version) {
		$this->version = $version;
	}
		
	/**
	 * @return String
	 */
	function getMarkdown() {
		return file_get_contents($this->getPath());
	}
	
	/**
	 * @param String $baselink 
	 * @return String
	 */
	function getHTML($baselink = null) {
		return DocumentationParser::parse($this, $baselink);
	}
}<commit_msg>BUGFIX: catch any errors thrown by incorrect paths nicer<commit_after><?php

/**
 * A specific page within a {@link DocumentationEntity}.
 * Has to represent an actual file, please use {@link DocumentationViewer}
 * to generate "virtual" index views.
 * 
 * @package sapphiredocs
 */
class DocumentationPage extends ViewableData {
	
	/**
	 * @var DocumentationEntity
	 */
	protected $entity;
	
	/**
	 * @var String 
	 */
	protected $relativePath;
	
	/**
	 * @var String
	 */
	protected $lang = 'en';
	
	/**
	 * @var String
	 */
	protected $version;
	
	/**
	 * @return DocumentationEntity
	 */
	function getEntity() {
		return $this->entity;
	}
	
	function setEntity($entity) {
		$this->entity = $entity;
	}
		
	/**
	 * @return String Relative path to file or folder within the entity (including file extension),
	 * but excluding version or language folders.
	 */
	function getRelativePath() {
		return $this->relativePath;
	}
	
	function setRelativePath($path) {
		$this->relativePath = $path;
	}
	
	/**
	 * Absolute path including version and lang folder.
	 * 
	 *  @return String 
	 */
	function getPath() {
		$path = realpath(rtrim($this->entity->getPath($this->version, $this->lang), '/') . '/' . trim($this->getRelativePath(), '/'));
		
		if(!file_exists($path)) {
			throw new InvalidArgumentException(sprintf(
				'Path could not be found. Module path: %s, file path: %s', 
				$this->entity->getPath(),
				$this->relativePath
			));
		}
		
		return $path;
	}
		
	function getLang() {
		return $this->lang;
	}
	
	function setLang($lang) {
		$this->lang = $lang;
	}
	
	function getVersion() {
		return $this->version;
	}
	
	function setVersion($version) {
		$this->version = $version;
	}
		
	/**
	 * @return String
	 */
	function getMarkdown() {
		try {
			$path = $this->getPath();
			
			return file_get_contents($path);
		}
		catch(InvalidArgumentException $e) {}
		
		return null;
	}
	
	/**
	 * @param String $baselink 
	 * @return String
	 */
	function getHTML($baselink = null) {
		return DocumentationParser::parse($this, $baselink);
	}
}
{'fraction_non_alphanumeric': 0.15137730603992924, 'fraction_numerical': 0.0, 'mean_word_length': 3.215122470713525, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '5255373', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1228, 'n_words': 317}