예제 #1
0
 /**
  * Reads the version number from a string
  *
  * @param string $text
  *
  * @return array
  * @throws \BuildException
  */
 public static function get($text)
 {
     $lines = GemsFile::toArray($text);
     // read the last line
     $version = trim(array_pop($lines));
     GemsAssert::notEmpty($version, "Last line of version file is empty.");
     GemsLog::log("Version: {$version}");
     // read the build number
     $numbers = explode('.', $version);
     GemsAssert::areEqual(count($numbers), 3, "Bad version format. Must be major.minor.build format.");
     GemsAssert::isTruthy(_::create($numbers)->all(function ($n) {
         return is_numeric($n);
     }), "Bad version format. Must 3 numeric values.");
     return _::create($numbers)->map(function ($n) {
         return (int) $n;
     });
 }
예제 #2
0
 /**
  * Set Property for File containing version formation
  *
  * @param string $file
  */
 public function setFile($file)
 {
     GemsAssert::noneEmptyString($file, "Expecting a string.");
     $this->file = $file;
 }