);
/**
- * @param $dir The root directory of the repo where the .git dir can be found
+ * @param $dir string The root directory of the repo where the .git dir can be found
*/
public function __construct( $dir ) {
$this->basedir = "{$dir}/.git/";
/**
* Check if a string looks like a hex encoded SHA1 hash
*
- * @param $str The string to check
+ * @param $str string The string to check
* @return bool Whether or not the string looks like a SHA1
*/
public static function isSHA1( $str ) {
/**
* Get an URL to a web viewer link to the HEAD revision.
*
- * @return string|false string if an URL is available or false otherwise.
+ * @return string|bool string if an URL is available or false otherwise.
*/
public function getHeadViewUrl() {
$config = "{$this->basedir}/config";
$url .= '.git';
}
foreach( $this->viewers as $repo => $viewer ) {
- $m = array();
$pattern = '#^' . $repo . '$#';
if ( preg_match( $pattern, $url ) ) {
$viewerUrl = preg_replace( $pattern, $viewer, $url );
/**
* @see self::getHeadSHA1
+ * @return string
*/
public static function headSHA1() {
return self::repo()->getHeadSHA1();
/**
* @see self::getCurrentBranch
+ * @return string
*/
public static function currentBranch() {
return self::repo()->getCurrentBranch();
/**
* @see self::getHeadViewUrl()
+ * @return bool|string
*/
public static function headViewUrl() {
return self::repo()->getHeadViewUrl();