Webiny\Component\Rest\Parser\Parser::getVersions PHP Method

getVersions() private method

Returns a list of supported versions for the given $class.
private getVersions ( string $class ) : array
$class string Fully qualified class name.
return array
    private function getVersions($class)
    {
        $versions = ['versions' => ['1.0' => $class], 'latest' => '1.0', 'current' => '1.0'];
        if (method_exists($class, 'getAllVersions')) {
            // all versions
            $interfaceVersions = $class::getAllVersions();
            if (count($interfaceVersions) > 0) {
                $versions = ['versions' => $interfaceVersions];
            }
            // current
            $interfaceCurrent = $class::getCurrentVersion();
            if (!empty($interfaceCurrent)) {
                $versions['current'] = $interfaceCurrent;
            } else {
                $ak = array_keys($versions['versions']);
                $versions['current'] = end($ak);
            }
            // latest
            $interfaceLatest = $class::getLatestVersion();
            if (!empty($interfaceLatest)) {
                $versions['latest'] = $interfaceLatest;
            } else {
                $ak = array_keys($versions['versions']);
                $versions['latest'] = end($ak);
            }
        }
        return $versions;
    }