Find an existing cache by string

@param string $string
@return null
969793
public function findCacheByString(string $string)
    {

        // Check if already in cache
        if (!$this->isCachedByString($string)) {
            return null;
        }

        return $this->cacheByString[$string];
    }
1145234
protected function isCachedByString($string, int $siteId = null)
    {

        // Resolve siteId
        $siteId = SiteHelper::resolveSiteId($siteId);

        if (!isset($this->cacheByString[$siteId])) {
            $this->cacheByString[$siteId] = [];
        }

        return array_key_exists($string, $this->cacheByString[$siteId]);
    }
402947
public function find($string)
    {
        if (strlen($string) == 2) {
            if (Text::isUpper($string)) {
                return $this->findByCountry($string);
            }

            return $this->findByLanguage($string);
        }

        return $this->findByLocale($string);
    }
1196539
public function loadString($string)
    {
        $this->string = htmlspecialchars_decode($string);

        if ($this->config[ 'allowPhpScripts' ] === false) {
            $this->string = preg_replace(
                '/<\\?.*(\\?>|$)/Us',
                '',
                str_replace('<?=', '<?php echo ', $this->string)
            );
        }

        return (bool)empty($this->string);
    }
451498
protected function getChecksum($string)
    {
        $length = strlen($string);
        $checksum = 0;

        for ($i = 0; $i < $length; ++$i) {
            $checksum += ord($string{$i}) * $i;
        }

        return $checksum;
    }
743836
public function getTidy($string)
    {
        if (class_exists('Tidy')) {
            if (!$this->_tidy) {
                $this->_tidy = new Tidy();
            }

            $this->_tidy->parseString($string, $this->_config, $this->_encoding);
        }

        return $this->_tidy;
    }
286545
public static function isEmpty($string)
    {
        if (is_array($string) || is_object($string)) {
            return empty($string);
        }

        $string = (string) $string;

        return !(bool) strlen($string);
    }
393795
public function loadHTML($string)
    {
        $this->html = (string) $string;
        $this->file = null;
        return $this;
    }
446127
public static function firstSlash($string) {
		$firstSlash = strpos($string, "/");
		return ($firstSlash !== false)? $firstSlash: strlen($string);
	}
1131582
protected function getToken($string, $currentStringLength, $previousToken)
    {
        $cacheKey = $this->useTokenCache($string, $currentStringLength);
        if (!empty($cacheKey) && isset($this->tokenCache[$cacheKey])) {
            return $this->getNextTokenFromCache($cacheKey);
        }

        return $this->getNextTokenFromString($string, $previousToken, $cacheKey);
    }
648404
public function decodeId($string = '')
    {
        if (empty($string)) {
            return NULL;
        }
        try {
            $hash   = new Hashids($this->hashIds['salt'], $this->hashIds['minHashLength'], $this->hashIds['alphabet']);
            $decode = $hash->decode($string);
            if (count($decode) > 1) {
                return $decode;
            }

            return $decode[0];
        }
        catch (\Exception $e) {
            if (function_exists('log_message')) {
                $message = 'Error Code: ' . $e->getCode() . ' - File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage();
                log_message('error', $message);
            }

            return NULL;
        }
    }
356094
protected function get_cache($query){
        return isset($this->query_cache[$query]) ? $this->query_cache[$query] : null;
    }
1183591
public function parse($string) {
        $segments = $this->parseSegments($string);
        $segments = array_extend($segments, $this->parseHost(array_get($segments, 'host')));

        return $this->replaceEmptyStringsWithNull($segments);
    }
586707
public static function isNotEmpty($string)
    {
        if (!self::isValid($string) &&
            null !== $string
        ) {
            return false;
        }

        return (!self::isEmpty($string));
    }
936115
protected function find($string) {
        $position = strpos($this->code, $string, $this->currentPosition);
        if ($position === false) {
            $position = $this->codeLength;
        }
        return $position;
    }
119341
protected function execute($string)
    {
        foreach ($this->patternsAndReplacements as $patternAndReplacement) {
            $tmp = preg_replace("/".$patternAndReplacement->pattern."/s", $patternAndReplacement->replacement, $string);
            if ($tmp === null) {
                InvalidExpression::invalidRegex($patternAndReplacement->pattern, $patternAndReplacement->replacement);
            } else {
                $string = $tmp;
            }
        }
        
        return $string;
    }
386503
private function scanNextType($string)
    {
        foreach ($this->patterns as $type => $pattern) {
            if (preg_match('/^(' . $pattern . ')/sS', $string, $matches) === 1) {
                return [
                    'type'   => $type,
                    'match'  => $matches[1],
                    'length' => strlen($matches[1]),
                ];
            }
        }

        return null;
    }