Last version-check data.

@since 160530 Update utils.

@param array|null `[time,version]`.

@return array Last version-check data.
432820
protected function lastVersionCheck(array $data = null): array
    {
        $default_empty_data = [
            'time'         => 0,
            'version'      => '',
            'product_slug' => '',
        ];
        if (isset($data)) { // Set automatically.
            $data['product_slug'] = $this->App->Config->©brand['§product_slug'];
        }
        $data = $this->s::sysOption('updater_last_version_check', $data);
        $data = is_array($data) ? $data : []; // Force array.

        $data = array_merge($default_empty_data, $data);
        $data = array_intersect_key($data, $default_empty_data);

        $data['time']         = (int) $data['time'];
        $data['version']      = (string) $data['version'];
        $data['product_slug'] = (string) $data['product_slug'];

        // NOTE: `$_REQUEST['force-check']` comes from WordPress core.
        // This is passed by the 'Check Again' button in `update-core.php`.

        // NOTE: Must ensure product slug is a match.
        // e.g., If they started w/ lite and upgraded to pro.

        if (!empty($_REQUEST['force-check'])) {
            $data = $default_empty_data; // Forcing a new check.
        } elseif (!$data['time'] || !$data['version'] || !$data['product_slug']
            || $data['product_slug'] !== $this->App->Config->©brand['§product_slug']) {
            $data = $default_empty_data; // Return all or none.
        }
        return $data;
    }
47468
public function getNextVersion($from)
    {
        $found = false;
        foreach (array_keys($this->versions) as $timestamp) {
            if ($from === null) {
                return $timestamp;
            }

            if ($timestamp == $from) {
                $found = true;
                continue;
            }

            if ($found) {
                return $timestamp;
            }
        }

        return;
    }
464713
public function lastModified($modified = null)
    {
        if ($modified && $modified > $this->last_modified) {
            $this->last_modified = $modified;
        }

        return $this->last_modified;
    }
985425
public function last()
    {
        if (!$this->isCollection()) {
            return $this;
        }

        return isset($this->data[0]) ? $this->box(ArrayUtility::last($this->data)) : null;
    }
1222122
private function getLastDate()
    {
        /* get the last date with calculated snapshots */
        $req = new AGetLastDateRequest();
        /** @var  AGetLastDateResponse $resp */
        $resp = $this->servGetLastDate->exec($req);
        $result = $resp->getLastDate();
        return $result;
    }
836985
public function checkVersion()
    {
        if ($this->checkCacheVersion()) {
            return;
        }
        $this->syncAssets();
        $this->cache->flushAll();
        $this->updateAutoloader();
        $this->updateCacheVersion();
    }
481161
public function getServerVersion()
	{
		try
		{
			$version = $this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
		}
		catch(\PDOException $e)
		{
			return NULL;
		}
		
		return $version;
	}
797864
public function checkPhpVersion()
    {
        $requirementFits = null;

        $minimalRequiredVersion = '7.0.0';
        $minimalRecommendedVersion = '7.0.0';
        $maximalRecommendedVersion = '7.1.9999';

        $installedPhpVersion = $this->getPhpVersion();

        if (version_compare($installedPhpVersion, $minimalRequiredVersion, '<')) {
            $requirementFits = static::MODULE_STATUS_BLOCKS_SETUP;
        }

        if (is_null($requirementFits) &&
            version_compare($installedPhpVersion, $minimalRecommendedVersion, '>=')
            && version_compare($installedPhpVersion, $maximalRecommendedVersion, '<=')) {
            $requirementFits = static::MODULE_STATUS_OK;
        }

        if (is_null($requirementFits)) {
            $requirementFits = static::MODULE_STATUS_FITS_MINIMUM_REQUIREMENTS;
        }

        return $requirementFits;
    }
317225
public function requestVersion(): array
    {
        try {
            $versions = json_decode(file_get_contents($this->apiURL), true)['packages']['orchid/platform'];

            return array_reverse($versions);
        } catch (\Exception $exception) {
            Log::alert($exception->getMessage());

            return [['version' => '0.0.0']];
        }
    }
1002494
public function getVersions()
    {
        while (
            !empty($this->version) &&
            substr_count($this->version, '.') < 2
        ) {
            $this->version .= '.0';
        }
        // Remove part by part of the version.
        $result = array_merge(
            [$this->version],
            $this->explode($this->version, '.')
        );
        asort($result);
        usort($result, function ($a, $b) {
            // PHP 7: Switch to the <=> "Spaceship" operator
            return strlen($b) - strlen($a);
        });
        return $this->filterDuplicates($result);
    }
1194776
private function _checkStructureVersion()
    {
        $result = $this->_query("SELECT num FROM version");
        if (!$result) return false;
        $row = @sqlite_fetch_array($result);
        if (!$row) {
            return false;
        }
        if (((int) $row['num']) != 1) {
            // old cache structure
            $this->_log('Zend_Cache_Backend_Sqlite::_checkStructureVersion() : old cache structure version detected => the cache is going to be dropped');
            return false;
        }
        return true;
    }
272037
public function lastReply()
    {
        try {
            $replies = ForumReply::where('post_id', $this->id)->get();

            if ($replies->isEmpty()) {
                return null;
            }

            $reply = $replies->last();

            return [
                'author' => $reply->author->name,
                'date' => $reply->created_at
            ];
        } catch (Exception $e) {
            return null;
        }
    }
396014
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;
    }
628302
protected function getVersion()
	{
		if (is_null($this->version))
		{
			// get the first version in versions
			$this->version = reset($this->versions);
		}

		return $this->version;
	}
1251800
protected function getLastEditedForVersion($version)
    {
        Deprecation::notice('5.0', 'Use getLastEditedAndStageForVersion instead');
        $result = $this->getLastEditedAndStageForVersion($version);
        if ($result) {
            return reset($result);
        }
        return null;
    }
665104
public function last()
	{
		$set = array_slice($this->list, -1, 1, true);
		
		return isset($set[0]) ? $set[0] : null;
	}
620
public function getPreviousVersion($from)
    {
        $lastTimestamp = 0;
        foreach (array_keys($this->versions) as $timestamp) {
            if ($timestamp == $from) {
                return $lastTimestamp;
            }
            $lastTimestamp = $timestamp;
        }

        return 0;
    }