<commit_before><?php
/**
 *
 *
 * PHP.Gt (http://php.gt)
 * @copyright Copyright Ⓒ 2014 Bright Flair Ltd. (http://brightflair.com)
 * @license Apache Version 2.0, January 2004. http://www.apache.org/licenses
 */
namespace Gt\Core;

class Path {

const DATABASE		= "database";
const PAGE			= "page";
const PUBLICFILES	= "publicfiles";
const ROOT			= "root";
const ASSET			= "asset";
const SCRIPT		= "script";
const STYLE			= "style";
const API			= "api";
const APILOGIC		= "apilogic";
const APITOOL		= "apitool";
const APIVIEW		= "apiview";
const SRC			= "src";
const WWW			= "www";
const GTROOT		= "gtroot";

/**
 * Returns the absolute path on disk to the requested path constant, while
 * fixing the path's case, so your application does not need to know if the
 * developer is using lower case, upper case, camel case, etc.
 *
 * @param string $name One of this class's constants.
 *
 * @return string The absolute path on disk.
 */
public static function get($name) {
	$p = null;

	switch($name) {
	case self::DATABASE:
		$p = self::get(self::SRC) . "/Database";
		break;

	case self::PAGE:
		$p = self::get(self::SRC) . "/Page";
		break;

	case self::PUBLICFILES:
		$p = self::get(self::SRC) . "/PublicFiles";
		break;

	case self::ROOT:
		$p = dirname($_SERVER["DOCUMENT_ROOT"]);
		break;

	case self::SCRIPT:
		$p = self::get(self::SRC) . "/Script";
		break;

	case self::API:
		$p = self::get(self::SRC) . "/API";
		break;

	case self::APILOGIC:
		$p = self::get(self::API) . "/Logic";
		break;

	case self::APITOOL:
		$p = self::get(self::API) . "/Tool";
		break;

	case self::APIVIEW:
		$p = self::get(self::API) . "/View";
		break;

	case self::SRC:
		$p = self::get(self::ROOT) . "/src";
		break;

	case self::STYLE:
		$p = self::get(self::SRC) . "/Style";
		break;

	case self::ASSET:
		$p = self::get(self::SRC) . "/Asset";
		break;

	case self::WWW:
		$p = self::get(self::ROOT) . "/www";
		break;

	case self::GTROOT:
		$p = realpath(__DIR__ . "/../../");
		break;

	default:
		throw new \UnexpectedValueException("Invalid path: $name");
	}

	return self::fixCase($p);
}

/**
 * Takes an absolute path and checks the case for each directory in the tree,
 * correcting it according to what is actually stored on disk.
 *
 * @param string $path Original path
 * @param bool|string $stripPrefix Defaults to false. Set to non-false string to
 * treat the returned path as a uri, removing the provided urlPath prefix
 * automatically in order to use as an absolute URI.
 * @param bool|string $stripSuffix Defaults to false. Set to non-false string to
 * automatically remove the provided string ending.
 *
 * @return string Correctly-cased path. Returns in URI style if $stripPrefix
 * is set to a non-null string.
 */
public static function fixCase($path,
$stripPrefix = false, $stripSuffix = false) {
	$pathArray = explode("/", $path);

	$currentPath = "";
	foreach ($pathArray as $i => $p) {
		if(!file_exists($currentPath . "/" . $p)) {
			if(!is_dir($currentPath)) {
				continue;
			}
<commit_msg>bool should be boolean<commit_after><?php
/**
 *
 *
 * PHP.Gt (http://php.gt)
 * @copyright Copyright Ⓒ 2014 Bright Flair Ltd. (http://brightflair.com)
 * @license Apache Version 2.0, January 2004. http://www.apache.org/licenses
 */
namespace Gt\Core;

class Path {

const DATABASE		= "database";
const PAGE			= "page";
const PUBLICFILES	= "publicfiles";
const ROOT			= "root";
const ASSET			= "asset";
const SCRIPT		= "script";
const STYLE			= "style";
const API			= "api";
const APILOGIC		= "apilogic";
const APITOOL		= "apitool";
const APIVIEW		= "apiview";
const SRC			= "src";
const WWW			= "www";
const GTROOT		= "gtroot";

/**
 * Returns the absolute path on disk to the requested path constant, while
 * fixing the path's case, so your application does not need to know if the
 * developer is using lower case, upper case, camel case, etc.
 *
 * @param string $name One of this class's constants.
 *
 * @return string The absolute path on disk.
 */
public static function get($name) {
	$p = null;

	switch($name) {
	case self::DATABASE:
		$p = self::get(self::SRC) . "/Database";
		break;

	case self::PAGE:
		$p = self::get(self::SRC) . "/Page";
		break;

	case self::PUBLICFILES:
		$p = self::get(self::SRC) . "/PublicFiles";
		break;

	case self::ROOT:
		$p = dirname($_SERVER["DOCUMENT_ROOT"]);
		break;

	case self::SCRIPT:
		$p = self::get(self::SRC) . "/Script";
		break;

	case self::API:
		$p = self::get(self::SRC) . "/API";
		break;

	case self::APILOGIC:
		$p = self::get(self::API) . "/Logic";
		break;

	case self::APITOOL:
		$p = self::get(self::API) . "/Tool";
		break;

	case self::APIVIEW:
		$p = self::get(self::API) . "/View";
		break;

	case self::SRC:
		$p = self::get(self::ROOT) . "/src";
		break;

	case self::STYLE:
		$p = self::get(self::SRC) . "/Style";
		break;

	case self::ASSET:
		$p = self::get(self::SRC) . "/Asset";
		break;

	case self::WWW:
		$p = self::get(self::ROOT) . "/www";
		break;

	case self::GTROOT:
		$p = realpath(__DIR__ . "/../../");
		break;

	default:
		throw new \UnexpectedValueException("Invalid path: $name");
	}

	return self::fixCase($p);
}

/**
 * Takes an absolute path and checks the case for each directory in the tree,
 * correcting it according to what is actually stored on disk.
 *
 * @param string $path Original path
 * @param boolean|string $stripPrefix Defaults to false. Set to non-false string
 * to treat the returned path as a uri, removing the provided urlPath prefix
 * automatically in order to use as an absolute URI.
 * @param boolean|string $stripSuffix Defaults to false. Set to non-false string
 * to automatically remove the provided string ending.
 *
 * @return string Correctly-cased path. Returns in URI style if $stripPrefix
 * is set to a non-null string.
 */
public static function fixCase($path,
$stripPrefix = false, $stripSuffix = false) {
	$pathArray = explode("/", $path);

	$currentPath = "";
	foreach ($pathArray as $i => $p) {
		if(!file_exists($currentPath . "/" . $p)) {
			if(!is_dir($currentPath)) {
				continue;
			}

{'fraction_non_alphanumeric': 0.16051629985106736, 'fraction_numerical': 0.0033096144299189145, 'mean_word_length': 3.620795107033639, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '3662981', 'n_tokens_mistral': 2264, 'n_tokens_neox': 2101, 'n_words': 657}