Utility::getRevHash()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 4
nc 2
nop 1
1
<?php
2
namespace common\components;
3
4
use yii;
5
6
class Utility {
7
  public static $REVISION_FILE = "./REVISION";
8
9
  public static function getGithubRevUrl($file = false) {
10
    if($hash = self::getRevHash($file)) {
11
      return "https://github.com/CorWatts/fasterscale/commit/$hash";
12
    }
13
    return false;
14
  }
15
16
  public static function getRevHash($file = false) {
17
    $file = $file ?: self::$REVISION_FILE;
18
    if(is_file($file) && is_readable($file)) {
19
      return substr(file_get_contents($file), 0, 7);
20
    }
21
    return false;
22
  }
23
24
}
25
26