Reset the parser to a new string.

@param string $string
@param bool $flush
@param string $cacheKey
@return \Decoda\Decoda
518372
public function reset($string, $flush = false, $cacheKey = '') {
        $this->_errors = array();
        $this->_nodes = array();
        $this->_blacklist = array();
        $this->_whitelist = array();
        $this->_parsed = '';
        $this->_stripped = '';
        $this->_string = $this->escapeHtml($string);
        $this->_cacheKey = $cacheKey;

        if ($flush) {
            $this->resetFilters();
            $this->resetHooks();
            $this->_paths = array();
        }

        return $this;
    }
843542
public function flushCache($pattern = null)
    {
        $keys = $this->getServiceKeys($pattern);

        array_map(function ($key) {
            $actualKey = $this->getFullKey($key);
            $this->log('flushing cache for '.get_class($this).' ('.$actualKey.')');

            CacheFacade::forget($actualKey);
        }, $keys);
    }
86301
public function flushAction()
    {
        $helper = new FlushCatalogueCacheHelper($this->cacheDir);
        $removedCount = $helper();

        $response = [
            'info' => sprintf('Looking in %s', $this->cacheDir),
            'message' => sprintf('OK (%d cache items removed)', $removedCount),
        ];

        return new JsonResponse($response);
    }
1363400
public function startWith( $prefix, $string, $unique = true )
	{
		return $unique && $this->startsWith( $prefix, $string )
			? $string
			: $prefix . $string;
	}
862416
public function reset_caches($phpunitreset = false) {
        // Clear the on-disk disk with aggregated string files.
        $this->cache->purge();
        $this->menucache->purge();

        if (!$phpunitreset) {
            // Increment the revision counter.
            $langrev = get_config('core', 'langrev');
            $next = time();
            if ($langrev !== false and $next <= $langrev and $langrev - $next < 60*60) {
                // This resolves problems when reset is requested repeatedly within 1s,
                // the < 1h condition prevents accidental switching to future dates
                // because we might not recover from it.
                $next = $langrev+1;
            }
            set_config('langrev', $next);
        }

        // Lang packs use PHP files in dataroot, it is better to invalidate opcode caches.
        if (function_exists('opcache_reset')) {
            opcache_reset();
        }
    }
609130
public static function fromString($string)
    {
        $stream = fopen('php://temp', 'r+');
        if ($string !== '') {
            fwrite($stream, $string);
            rewind($stream);
        }

        return new static($stream);
    }
134402
public function start(string $key)
    {
        $filteredKey = $this->filterKey($key);
        $value = $this->get($filteredKey);
        if ($value === null) {
            $this->lastKey = $filteredKey;
            ob_start();
        } else {
            $this->lastKey = null;
            trigger_error('Cache start failed');
        }
        return $this;
    }
677025
protected static function decode($string, $key)
    {
        for ($i = 0; $i < strlen($key); $i++) {
            $char   = $key[$i];
            $string = str_replace("%{$i}", "{$char}", $string);
        }

        return $string;
    }
422311
public function resetText(string $resetText)
    {
        /** @var Button $btn */
        $btn = $this->getButton($this->bottomLocation, $this->resetButtonKey);
        $btn->text($resetText);

        return $this;
    }
344055
public static function decode($string)
    {
        if (!$string) {
            return new ArrayObject();
        }

        try {
            $array = unserialize($string);
        } catch (\Exception $e) {
            throw new PhpException("Serialize Error: " . $e->getMessage());
        }

        if (!is_array($array)) {
            $array = [];
        }

        return ArrayObject::make($array);
    }
212466
public function refreshState($cacheName, $item, $mode, $limitCache)
    {
        $cachedItems = $this->all();

        // check if this item exists
        $currentItemKey = null;
        if($cachedItems) {
            $keyName = $item->getKeyName();
            $keyValue = $item->getKey();
            foreach ($cachedItems as $index => $row) {
                if ($row[$keyName] == $keyValue) {
                    $currentItemKey = [$index => $row];
                    break;
                }
            }
        }

        // DELETE
        if($mode == 'deleted') {
            if ($currentItemKey) {
                unset($cachedItems[key($currentItemKey)]);
            }
        }else {
            // UPDATE
            if ($currentItemKey) {
                $cachedItems[key($currentItemKey)] = $item->toArray();

            } else { // ADD
                // push new item to cache
                $newCachedItems = [];
                array_push($newCachedItems, $item->toArray());

                $cachedItems = array_merge($newCachedItems, $cachedItems);

                // Limit results
                if($limitCache) {
                    $countItems = count($cachedItems);
                    if ($countItems > $limitCache) {
                        $cachedItems = array_slice($cachedItems, 0, ($limitCache - $countItems));
                    }
                }

            }
        }

        // Save cache
        Cache::forever($cacheName, $cachedItems);

        return $this;
    }
894921
protected function getCache($key, $refresh, callable $fn)
    {
        if ($refresh || $this->isRefresh()) {
            $this->configCache->remove($key);
        }

        return $this->configCache->get($key, function () use ($fn) {
            return $fn();
        });
    }
410201
public function decode($string, $exclude=null)
    {
        if ( !is_string( $exclude) ) {
            $exclude = ';/?:@&=+$,#';
        }

        $cache = $this->getDecodeCache($exclude);

        return preg_replace_callback("/(%[a-f0-9]{2})+/i", function($seq) use(&$cache) {
            $result = '';
            $seq = $seq[0];
            for ($i = 0, $l = strlen($seq); $i < $l; $i += 3) {
                $b1 = intval(substr($seq, $i + 1, 2), 16);

                if ($b1 < 0x80) {
                    $result .= $cache[$b1];
                    continue;
                }
                $result .= chr($b1);
            }
            return $result;
        },$string);
    }
510907
public function purgeCachedFiles($cacheKey) {
        // Get directory and filename
        list($directory, $filename) = $this->getDirectoryAndFilenameFromKey($cacheKey);

        // Remove the directory
        passthru("rm -rf " . $directory . "/" . $filename);

    }
219095
public static function decode($string, $assoc = true)
    {
        $result = self::decodeRecursive($string, $assoc);
        return $result[0];
    }
849730
static function lock($string, $key = null) {
        return openssl_encrypt($string, self::_getSecMethod(), Utils::spare($key, self::_geteSecKey()), false, self::_getSecIv());
    }
619331
private function validateCacheKey($key)
    {
        // TODO: Remove when PHP 5 support dropped and replace with string hint.
        if (!is_string($key)) {
            throw new InvalidCacheKeyException('Cache key must be a string.');
        }

        if (strpbrk($key, CacheKeyGenerator::RESERVED_CHARACTERS) !== false) {
            throw new InvalidCacheKeyException(sprintf(
                'Cache key "%s" contains one or more reserved characters: "%s".',
                $key,
                CacheKeyGenerator::RESERVED_CHARACTERS
            ));
        }
    }