/** * @param self $preRelease * @return int (> 0 if $this > $preRelease, < 0 if $this < $preRelease, 0 if equal) */ public function compareTo(PreRelease $preRelease) { $pr1Ids = array_values($this->getIdentifiers()); $pr2Ids = array_values($preRelease->getIdentifiers()); $pr1Count = count($pr1Ids); $pr2Count = count($pr2Ids); $limit = min($pr1Count, $pr2Count); for ($i = 0; $i < $limit; $i++) { $pr1IdVal = $pr1Ids[$i]->getValue(); $pr2IdVal = $pr2Ids[$i]->getValue(); if ($pr1IdVal == $pr2IdVal) { continue; } return $this->comparePreReleaseIdentifierValues($pr1IdVal, $pr2IdVal); } return $pr1Count - $pr2Count; }
/** * @return array */ public function toArray() { return ['major' => $this->major, 'minor' => $this->minor, 'patch' => $this->patch, 'preRelease' => $this->preRelease->toArray(), 'build' => $this->build->toArray()]; }