protected static function storageUnitFromOptionValue($optionValue) { $optionValue = CString::toLowerCase($optionValue); if (CString::endsWith($optionValue, "k")) { return CUUnit::KILOBYTE; } if (CString::endsWith($optionValue, "m")) { return CUUnit::MEGABYTE; } if (CString::endsWith($optionValue, "g")) { return CUUnit::GIGABYTE; } if (CString::endsWith($optionValue, "t")) { return CUUnit::TERABYTE; } return CUUnit::BYTE; }
/** * Adds a path component to a path, separating them with a slash if needed, and returns the combined path. * * If the specified path component already starts with "/", it still results in a single "/" as the separator. And, * as a special case, if the base path is empty, the returned string is the same as the specified path component. * * @param string $basePath The base path (can be absolute or relative). * @param string $component The path component to be added to the base path (cannot be absolute). * * @return CUStringObject The combined path. */ public static function add($basePath, $component) { assert('is_cstring($basePath) && is_cstring($component)', vs(isset($this), get_defined_vars())); assert('!CString::isEmpty($component)', vs(isset($this), get_defined_vars())); if (CString::isEmpty($basePath)) { return $component; } if (!CString::endsWith($basePath, "/")) { $basePath .= "/"; } return $basePath . $component; }
/** * Echoes a message into the output and, if logging is enabled, into the log file, adding a space after the * message's text unless the message is already ending in a space. * * @param string $message The message to be echoed. * @param bool $writeToLog **OPTIONAL. Default is** `true`. If logging is enabled, tells whether the message * should also be written to the log file. * * @return void */ public static function speak($message, $writeToLog = true) { assert('is_cstring($message) && is_bool($writeToLog)', vs(isset($this), get_defined_vars())); if (!CString::endsWith($message, " ")) { $message .= " "; } echo $message; if ($writeToLog && isset(self::$ms_logFp)) { self::writeToLog($message); } }