コード例 #1
0
ファイル: Build.php プロジェクト: Jadoube-Initiative/phpPGN
 /**
  * Parse a build part string
  *
  * A build part can look like build.11.e0f985a
  *
  * @param  string       $string
  * @return BuildVersion
  **/
 public static function parse($string)
 {
     // Explode over '.'
     $parts = explode('.', $string);
     // Instantiate
     $buildVersion = new BuildVersion();
     // No parts is no build?
     if (count($parts) === 0) {
         return $buildVersion;
     }
     // Discard "build" string should it prepend the build
     if ($parts[0] === 'build') {
         array_shift($parts);
     }
     // If the first part is a number it's the build number
     if (isset($parts[0]) && is_numeric($parts[0])) {
         $buildVersion->setNumber((int) array_shift($parts));
     }
     // All other parts are custom and can simply be put on a stack
     foreach ($parts as $part) {
         $buildVersion->addPart($part);
     }
     // Return
     return $buildVersion;
 }
コード例 #2
0
ファイル: Compare.php プロジェクト: joelpet/syncany-website
 /**
  * Is a build version greater than another one?
  *
  * @param  Build $v1
  * @param  Build $v2
  * @return bool
  */
 private static function buildGreaterThan(Build $v1, Build $v2)
 {
     return $v1->getNumber() > $v2->getNumber();
 }