This was supposed to be static
This was supposed to be static

<?php <?php
/** /**
* GitPHP Util * GitPHP Util
* *
* Utility functions * Utility functions
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
*/ */
   
/** /**
* Util class * Util class
* *
* @package GitPHP * @package GitPHP
*/ */
class GitPHP_Util class GitPHP_Util
{ {
   
/** /**
* AddSlash * AddSlash
* *
* Adds a trailing slash to a directory path if necessary * Adds a trailing slash to a directory path if necessary
* *
* @access public * @access public
* @static * @static
* @param string $path path to add slash to * @param string $path path to add slash to
* @param $filesystem true if this is a filesystem path (to also check for backslash for windows paths) * @param $filesystem true if this is a filesystem path (to also check for backslash for windows paths)
* @return string $path with a trailing slash * @return string $path with a trailing slash
*/ */
public static function AddSlash($path, $filesystem = true) public static function AddSlash($path, $filesystem = true)
{ {
if (empty($path)) if (empty($path))
return $path; return $path;
   
$end = substr($path, -1); $end = substr($path, -1);
   
if (!(( ($end == '/') || ($end == ':')) || ($filesystem && GitPHP_Util::IsWindows() && ($end == '\\')))) { if (!(( ($end == '/') || ($end == ':')) || ($filesystem && GitPHP_Util::IsWindows() && ($end == '\\')))) {
if (GitPHP_Util::IsWindows() && $filesystem) { if (GitPHP_Util::IsWindows() && $filesystem) {
$path .= '\\'; $path .= '\\';
} else { } else {
$path .= '/'; $path .= '/';
} }
} }
   
return $path; return $path;
} }
   
/** /**
* IsWindows * IsWindows
* *
* Tests if this is running on windows * Tests if this is running on windows
* *
* @access public * @access public
* @static * @static
* @return bool true if on windows * @return bool true if on windows
*/ */
public static function IsWindows() public static function IsWindows()
{ {
return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
} }
   
/** /**
* Is64Bit * Is64Bit
* *
* Tests if this is a 64 bit machine * Tests if this is a 64 bit machine
* *
* @access public * @access public
* @static * @static
* @return bool true if on 64 bit * @return bool true if on 64 bit
*/ */
public function Is64Bit() public static function Is64Bit()
{ {
return (strpos(php_uname('m'), '64') !== false); return (strpos(php_uname('m'), '64') !== false);
} }
   
} }
   
comments