Returns the timestamp of the cached asset

@param string $type
@param string $hash
@param string $version
@return integer
338987
public function getCachedAssetTimestamp($type, $hash, $version)
    {
        if (!$this->isCached($type, $hash, $version)) {
            return 0;
        }

        return $this->cachedFiles[$hash]['timestamp'];
    }
1090086
public static function get_time($path, $type = 'modified', $area = null)
	{
		$path = static::instance($area)->get_path($path);

		if ( ! file_exists($path))
		{
			throw new \InvalidPathException('Path: "'.$path.'" is not a directory or a file, cannot get creation timestamp.');
		}

		if ($type === 'modified')
		{
			return filemtime($path);
		}
		elseif ($type === 'created')
		{
			return filectime($path);
		}
		else
		{
			throw new \UnexpectedValueException('File::time $type must be "modified" or "created".');
		}
	}
6824
public function hash($type = 'sha1') {
		if (!isset($this->hash[$type])) {
			$this->hash[$type] = hash_file($type, $this->filename);
		}
		return $this->hash[$type];
	}
637839
protected function getNewLines($type, $version, $comment)
    {
        list($major, $minor, $patch) = explode('.', $version);
        if ($type == 'major') {
            $title = "version $major  $comment";

            return array_merge(
                array(
                    '',
                    strtoupper($title),
                    str_pad('', strlen($title), '='),
                ),
                $this->getNewLines('minor', $version, $comment)
            );
        } elseif ($type == 'minor') {
            return array_merge(
                array(
                    '',
                    "   Version $major.$minor - $comment",
                ),
                $this->getNewLines('patch', $version, 'initial release')
            );
        } else { //patch
            $date = $this->getFormattedDate();

            return array(
                "      $date  $version  $comment",
            );
        }
    }
694897
public function decode($hash, $type = '')
    {
        if (strlen($hash) !== 11) {
            return false;
        }

        if (!isset($this->_keys[$type])) {
            if ($this->_key === null) {
                $this->_key = $this->crypt->getDerivedKey('secint');
            }

            $this->_keys[$type] = md5($this->_key . $type, true);
        }

        $r = unpack('Vid/Vr', mcrypt_decrypt(MCRYPT_XTEA, $this->_keys[$type], base64_decode($hash . '='), MCRYPT_MODE_ECB));

        if ($r['r'] & 0xFFFF) {
            return false;
        } else {
            return $r['id'];
        }
    }
18822
public function saveToCache($type, $slotname, $version, ChunkModel $chunk = null)
    {
        $key = $this->getCacheKey($type, $slotname, $version);

        $this->cache->forever($key, $chunk);
    }
1371864
public function resolve(string $type, string $resource, array $parameters = [], $version = null)
    {
        $version = $version ?? $this->version;

        if (str_contains($resource, '.')) {
            list($resource, $related) = explode('.', $resource);
            $resourceDefinition = $this->loadRelatedDefinition($version, $resource, $related, $type);
        } else {
            $resourceDefinition = $this->loadDefinition($version, $resource, $type);
        }

        return $this->app->make($resourceDefinition, $parameters);
    }
1306006
protected static function _cache($type, $key, $value = false)
    {
        $key = '_' . $key;
        $type = '_' . $type;
        if ($value !== false) {
            self::$_cache[$type][$key] = $value;
            return $value;
        }
        if (!isset(self::$_cache[$type][$key])) {
            return false;
        }
        return self::$_cache[$type][$key];
    }
1304343
public function getMigrationSql($version, $increment)
    {
        // I could use the GLOB_BRACE but it is not supported on ALPINE distros.
        // So, I have to call multiple times to simulate the braces.

        if (intval($version) != $version) {
            throw new \InvalidArgumentException("Version '$version' should be a integer number");
        }
        $version = intval($version);

        $filePattern = $this->folder
            . "/migrations"
            . "/" . ($increment < 0 ? "down" : "up")
            . "/*.sql";

        $result = array_filter(glob($filePattern), function ($file) use ($version) {
            return preg_match("/^0*$version(-dev)?\.sql$/", basename($file));
        });

        // Valid values are 0 or 1
        if (count($result) > 1) {
            throw new InvalidMigrationFile("You have two files with the same version number '$version'");
        }

        foreach ($result as $file) {
            if (intval(basename($file)) === $version) {
                return $file;
            }
        }
        return null;
    }
1267179
public function Link($name, $type, $version = 'latest')
    {
        $type = strtolower($type);

        //Gets data
        $data = $this->includeLibraryService->getData($name, $type, $version);

        //Returns the href or src part
        if (null !== $data) {
            return 'css' == $type ? $data['href'] : $data['src'];
        }

        //Throws an error if not found
        throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_link()" was not found. Please check name and supported library/versions.');
    }
1178668
public function getVersion(string $id, int $version = 1): array
    {
        $this->setFile($id);
        $id = Check::name(pathinfo($id, PATHINFO_FILENAME));
        try {
            $fileName = str_replace("{$id}.json", "version/{$id}#{$version}.json", $this->file);
            if (file_exists($fileName))
                return array_merge(["id" => $id], json_decode(file_get_contents($fileName), true));
        } catch (\Exception $e) {
            return [];
        }
        return [];
    }
510019
public static function getUserID($hash, $type)
    {
        self::removeExpired($type);
        $db = Database::connection();
        $uID = $db->fetchColumn("SELECT uID FROM UserValidationHashes WHERE uHash = ? AND type = ?", array($hash, $type));
        if (is_numeric($uID) && $uID > 0) {
            return $uID;
        } else {
            return false;
        }
    }
816480
private function doLoadMetadata($type)
    {
        if (null !== $meta = $this->getFromMemory($type)) {
            $this->dispatchMetadataEvent(Events::onMetadataCacheLoad, $meta);
            // Found in memory.
            return $meta;
        }

        if (null !== $meta = $this->getFromCache($type)) {
            // Found in cache.
            $this->dispatchMetadataEvent(Events::onMetadataCacheLoad, $meta);
            $this->setToMemory($meta);
            return $meta;
        }
        return null;
    }
114165
public function cache($time, $type = 'app', $key = null)
    {
        return new Cached($this, $time, $type, $key);
    }
1134763
public function isCached($type, $hash, $version)
    {
        // If the base file isn't cached we do not need to check the file names
        if (!isset($this->cachedFiles[$hash])) {
            return false;
        }
        
        $searchedFile = $this->buildFilePath($type, $hash, $version);
        foreach ($this->cachedFiles as $baseFileHash => $cachedFile) {
            if ($cachedFile['file'] === $searchedFile) {
                return true;
            }
        }
        
        return false;
    }
620
public function getPreviousVersion($from)
    {
        $lastTimestamp = 0;
        foreach (array_keys($this->versions) as $timestamp) {
            if ($timestamp == $from) {
                return $lastTimestamp;
            }
            $lastTimestamp = $timestamp;
        }

        return 0;
    }
918995
protected function getVersion($type)
    {
        return $this->git->isVersionComingFromGit()
            ? $this->git->version($type)
            : $this->config->get("current.{$type}");
    }