protected function array_slice_cached(&$array, $offset, $length = null)
    {
        static $lastOffset = null;
        static $lastLength = null;
        static $cache      = null;

        // PHP has no support for by-reference comparing.
        // to prevent false positive hits, reset the cache when the oldWords or newWords is changed.
        if ($this->resetCache === true) {
            $cache = null;

            $this->resetCache = false;
        }

        if (
            $cache !== null &&
            $lastLength === $length &&
            $lastOffset === $offset
        ) { // Hit
            return $cache;
        } // Miss

        $lastOffset = $offset;
        $lastLength = $length;

        $cache = implode('', array_slice($array, $offset, $length));

        return $cache;
    }