예제 #1
1
 /**
  * Get the revision number from the local git clone data.
  *
  * @param int $length The length of the revision hash to return
  *
  * @return string|void
  */
 public static function getRevision($length = 10)
 {
     $revision = Cache::call("revision", function () {
         $path = static::path(".git");
         if (!is_dir($path)) {
             return;
         }
         $head = $path . "/HEAD";
         if (!file_exists($head)) {
             return;
         }
         $data = File::getContents($head);
         if (!preg_match("/ref: ([^\\s]+)\\s/", $data, $matches)) {
             return;
         }
         $ref = $path . "/" . $matches[1];
         if (!file_exists($ref)) {
             return;
         }
         return File::getContents($ref);
     });
     if ($length > 0) {
         return substr($revision, 0, $length);
     } else {
         return $revision;
     }
 }
예제 #2
0
 /**
  * Get the currencies supported by the Html class methods.
  *
  * @param boolean $symbols Whether to return a multi-dimensional array with the symbols of a currency, or just the currency codes and their names
  *
  * @return array Keyed by the currency code, value depends on the $symbols parameter
  */
 public static function getCurrencies($symbols = null)
 {
     $currencies = Cache::call("get-currencies", function () {
         $currencies = Yaml::decodeFromFile(__DIR__ . "/../data/currencies.yml");
         return array_map(function ($data) {
             if (!isset($data["prefix"])) {
                 $data["prefix"] = "";
             }
             if (!isset($data["suffix"])) {
                 $data["suffix"] = "";
             }
             return $data;
         }, $currencies);
     });
     if ($symbols) {
         return $currencies;
     }
     $return = [];
     foreach ($currencies as $key => $val) {
         $return[$key] = $val["title"];
     }
     return $return;
 }