=%1$s', $currentParts[0] + 1)); $minorCandidates = SemVer::satisfiedBy($latest, sprintf('~%1$s.%2$s', $currentParts[0], $currentParts[1] + 1)); $patchCandidates = SemVer::satisfiedBy($latest, sprintf('>=%1$s.%2$s.%3$s <%1$s.%3$s', $currentParts[0], $currentParts[1], $currentParts[2] + 1, $currentParts[1] + 1)); $hasMajor = !empty($majorCandidates); $hasMinor = !empty($minorCandidates); $hasPatch = !empty($patchCandidates); $isPreRelease = $isGitRelease || array_key_exists(4, $currentParts); $hasMultiMajor = count($majorCandidates) > 1; if ($isPreRelease) { // orange "warning" if you are on unreleased code $class = 'update2'; } else if ($hasPatch || $hasMultiMajor) { // current patch or more than 1 major behind $class = 'outdated'; } else if ($hasMinor) { // green warning for feature update $class = 'update'; } else if ($hasMajor) { // orange warning for 1 major beind $class = 'update2'; } else { $class = 'uptodate'; } $latest = SemVer::rsort($latest); $highestVersion = $latest[0]; $data = (object) array( 'link' => $link, 'latest' => $highestVersion, 'current' => $current, 'hasPatch' => $hasPatch, 'hasMinor' => $hasMinor, 'hasMajor' => $hasMajor, 'isPreRelease' => $isPreRelease, 'hasMultiMajor' => $hasMultiMajor, ); $result = sprintf('', json_encode($data)) . "
"; return $result; } }