Beispiel #1
0
 /**
  * Compare versions.
  *
  *  (4.0.0 > 4.0.0-alpha1, 4.0.0 < 4.0.1)
  *
  * @param Version $other
  * @return int negative for smaller version, 0 for equal, positive for later version
  */
 public function compareTo(Version $other)
 {
     $diff = $this->getMajor() - $other->getMajor();
     if ($diff) {
         return $diff;
     }
     $diff = $this->getMinor() - $other->getMinor();
     if ($diff) {
         return $diff;
     }
     $diff = $this->getPatch() - $other->getPatch();
     if ($diff) {
         return $diff;
     }
     // Compare stability
     $diff = $this->compareStabliity($this->getStability(), $other->getStability());
     if ($diff) {
         return $diff;
     }
     // Fall back to stability type (e.g. alpha1 vs alpha2)
     $diff = $this->getStabilityVersion() - $other->getStabilityVersion();
     return $diff;
 }
Beispiel #2
0
 /**
  * Get changelog path
  *
  * @param Version $version
  * @return string
  */
 public function getChangelogPath(Version $version)
 {
     $cowData = $this->getCowData();
     // If generating via markdown committed to source control
     if (empty($cowData['changelog-path'])) {
         return null;
     }
     $path = Format::formatString($cowData['changelog-path'], ['stability' => $version->getStability(), 'stabilityVersion' => $version->getStabilityVersion(), 'major' => $version->getMajor(), 'minor' => $version->getMinor(), 'patch' => $version->getPatch(), 'version' => $version->getValue(), 'versionStable' => $version->getValueStable()]);
     // Collapse duplicate //
     return str_replace('//', '/', $path);
 }