<commit_before><?php

namespace G4\Config;

use Zend\Config\Reader\Ini as Reader;
use G4\Log\Writer;

class Config
{
    private $cachingEnabled = false;

    private $cachePath;

    private $data;

    private $path;

    private $sections;

    private $section;

    public function setPath($path)
    {
        $this->path = $path;
        return $this;
    }

    public function setSection($section)
    {
        $this->section = $section;
        return $this;
    }

    public function setCachingEnabled($flag)
    {
        $this->cachingEnabled = (bool) $flag;
        return $this;
    }

    public function setCachePath($cachePath)
    {
        $this->cachePath = (string) $cachePath;
        return $this;
    }

    private function formatCacheFilename()
    {
        $segments = array(
            __NAMESPACE__,
            __CLASS__,
            $this->section,
        );

        // section can be empty, so remove it
        $filename = md5(implode('~', array_filter($segments)));

        if(!is_writable($this->cachePath)) {
            throw new \Exception('Cache file path is not writable');
        }

        return $this->cachePath . $filename;
    }

    private function getFromCache()
    {
        $realCachePath = realpath($this->formatCacheFilename());

        if(false === $realCachePath) {
            return null;
        }

        if(!is_readable($realCachePath)) {
            throw new \Exception('Cache file path is not readable');<commit_msg>added $path to array which is used to create hash for formatting cache filename this will allow multiple config files to be cached<commit_after><?php

namespace G4\Config;

use Zend\Config\Reader\Ini as Reader;
use G4\Log\Writer;

class Config
{
    private $cachingEnabled = false;

    private $cachePath;

    private $data;

    private $path;

    private $sections;

    private $section;

    public function setPath($path)
    {
        $this->path = $path;
        return $this;
    }

    public function setSection($section)
    {
        $this->section = $section;
        return $this;
    }

    public function setCachingEnabled($flag)
    {
        $this->cachingEnabled = (bool) $flag;
        return $this;
    }

    public function setCachePath($cachePath)
    {
        $this->cachePath = (string) $cachePath;
        return $this;
    }

    private function formatCacheFilename()
    {
        $segments = array(
            __NAMESPACE__,
            __CLASS__,
            $this->path,
            $this->section,
        );

        // section can be empty, so remove it
        $filename = md5(implode('~', array_filter($segments)));

        if(!is_writable($this->cachePath)) {
            throw new \Exception('Cache file path is not writable');
        }

        return $this->cachePath . $filename;
    }

    private function getFromCache()
    {
        $realCachePath = realpath($this->formatCacheFilename());

        if(false === $realCachePath) {
            return null;
        }

        if(!is_readable($realCachePath)) {
            throw new \Exception('Cache file path is not readable');
{'fraction_non_alphanumeric': 0.11235595390524968, 'fraction_numerical': 0.0019206145966709346, 'mean_word_length': 2.109452736318408, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5646548', 'n_tokens_mistral': 908, 'n_tokens_neox': 870, 'n_words': 226}