public static function getJoomlaVersion($base)
    {
        $key = md5($base);

        if (!isset(self::$_versions[$key]))
        {
            $canonical = function($version) {
                if (isset($version->RELEASE)) {
                    return 'v' . $version->RELEASE . '.' . $version->DEV_LEVEL;
                }

                // Joomla 3.5 and up uses constants instead of properties in JVersion
                $className = get_class($version);
                if (defined("$className::RELEASE")) {
                    return $version::RELEASE . '.' . $version::DEV_LEVEL;
                }

                return 'unknown';
            };

            $files = array(
                'joomla-cms'           => '/libraries/cms/version/version.php',
                'joomla-cms-new'       => '/libraries/src/Version.php', // 3.8+
                'joomlatools-platform' => '/lib/libraries/cms/version/version.php',
                'joomla-1.5'           => '/libraries/joomla/version.php'
            );

            $code        = false;
            $application = false;
            foreach ($files as $type => $file)
            {
                $path = $base . $file;

                if (file_exists($path))
                {
                    $code        = $path;
                    $application = $type;

                    break;
                }
            }

            if ($code !== false)
            {
                if (!defined('JPATH_PLATFORM')) {
                    define('JPATH_PLATFORM', self::buildTargetPath('/libraries', $base));
                }

                if (!defined('_JEXEC')) {
                    define('_JEXEC', 1);
                }

                $identifier = uniqid();

                $source = file_get_contents($code);
                $source = preg_replace('/<\?php/', '', $source, 1);

                $pattern     = $application == 'joomla-cms-new' ? '/class Version/i' : '/class JVersion/i';
                $replacement = $application == 'joomla-cms-new' ? 'class Version' . $identifier : 'class JVersion' . $identifier;

                $source = preg_replace($pattern, $replacement, $source);

                eval($source);

                $class   = $application == 'joomla-cms-new' ? '\\Joomla\\CMS\\Version'.$identifier : 'JVersion'.$identifier;
                $version = new $class();

                self::$_versions[$key] = (object) array('release' => $canonical($version), 'type' => $application);
            }
            else self::$_versions[$key] = false;
        }

        if (!self::$_versions[$key] && self::isKodekitPlatform($base)) {
            self::$_versions[$key] = (object) array('type' => 'kodekit-platform', 'release' => 'n/a');
        }
        
        return self::$_versions[$key];
    }