<commit_before><?php
class Kwf_Assets_Dependency_File extends Kwf_Assets_Dependency_Abstract
{
    protected $_fileName;
    private $_mtimeCache;
    private $_fileNameCache;

    public function __construct($fileNameWithType)
    {
        if (substr($fileNameWithType, 0, 1) == '/') {
            throw new Kwf_Exception('Don\'t use absolute file names');
        }
        if (!$fileNameWithType) {
            throw new Kwf_Exception("Invalid filename");
        }
        $this->_fileName = $fileNameWithType;

        //check commented out, only required for debugging
        //if (!file_exists($this->getAbsoluteFileName())) {
        //    throw new Kwf_Exception("File not found: '$this->_fileName' ('{$this->getAbsoluteFileName()}')");
        //}
    }

    public function getContents($language)
    {
        return file_get_contents($this->getAbsoluteFileName());
    }

    public function getType()
    {
        return substr($this->_fileName, 0, strpos($this->_fileName, '/'));
    }

    public function getFileNameWithType()
    {
        return $this->_fileName;
    }

    protected static function _getAllPaths()
    {
        static $paths;
        if (!isset($paths)) {
            $cacheId = 'assets-file-paths';
            $paths = Kwf_Cache_SimpleStatic::fetch($cacheId);
            if ($paths === false) {
                $paths = array(
                    'web' => '.',
                    'webThemes' => 'themes',
                );
                $vendors[] = KWF_PATH; //required for kwf tests, in web kwf is twice in $vendors but that's not a problem
                $vendors[] = '.';
                $vendors = array_merge($vendors, glob(VENDOR_PATH."/*/*"));
                foreach ($vendors as $i) {
                    if (is_dir($i) && file_exists($i.'/dependencies.ini')) {
                        $c = new Zend_Config_Ini($i.'/dependencies.ini');
                        if ($c->config) {
                            $dep = new Zend_Config_Ini($i.'/dependencies.ini', 'config');
                            $paths[$dep->pathType] = $i;
                        }
                    }
                }
                Kwf_Cache_SimpleStatic::add($cacheId, $paths);
            }
        }
        return $paths;
    }

    public function getAbsoluteFileName()
    {
        if (isset($this->_fileNameCache)) return $this->_fileNameCache;
        $paths = self::_getAllPaths();<commit_msg>added webComponents path for Kwf/Assets/Dependency/File.php<commit_after><?php
class Kwf_Assets_Dependency_File extends Kwf_Assets_Dependency_Abstract
{
    protected $_fileName;
    private $_mtimeCache;
    private $_fileNameCache;

    public function __construct($fileNameWithType)
    {
        if (substr($fileNameWithType, 0, 1) == '/') {
            throw new Kwf_Exception('Don\'t use absolute file names');
        }
        if (!$fileNameWithType) {
            throw new Kwf_Exception("Invalid filename");
        }
        $this->_fileName = $fileNameWithType;

        //check commented out, only required for debugging
        //if (!file_exists($this->getAbsoluteFileName())) {
        //    throw new Kwf_Exception("File not found: '$this->_fileName' ('{$this->getAbsoluteFileName()}')");
        //}
    }

    public function getContents($language)
    {
        return file_get_contents($this->getAbsoluteFileName());
    }

    public function getType()
    {
        return substr($this->_fileName, 0, strpos($this->_fileName, '/'));
    }

    public function getFileNameWithType()
    {
        return $this->_fileName;
    }

    protected static function _getAllPaths()
    {
        static $paths;
        if (!isset($paths)) {
            $cacheId = 'assets-file-paths';
            $paths = Kwf_Cache_SimpleStatic::fetch($cacheId);
            if ($paths === false) {
                $paths = array(
                    'web' => '.',
                    'webComponents' => 'components',
                    'webThemes' => 'themes',
                );
                $vendors[] = KWF_PATH; //required for kwf tests, in web kwf is twice in $vendors but that's not a problem
                $vendors[] = '.';
                $vendors = array_merge($vendors, glob(VENDOR_PATH."/*/*"));
                foreach ($vendors as $i) {
                    if (is_dir($i) && file_exists($i.'/dependencies.ini')) {
                        $c = new Zend_Config_Ini($i.'/dependencies.ini');
                        if ($c->config) {
                            $dep = new Zend_Config_Ini($i.'/dependencies.ini', 'config');
                            $paths[$dep->pathType] = $i;
                        }
                    }
                }
                Kwf_Cache_SimpleStatic::add($cacheId, $paths);
            }
        }
        return $paths;
    }

    public function getAbsoluteFileName()
    {
        if (isset($this->_fileNameCache)) return $this->_fileNameCache;
        $paths = self::_getAllPaths();
{'fraction_non_alphanumeric': 0.1333199276090891, 'fraction_numerical': 0.0012065151819827067, 'mean_word_length': 1.8038331454340473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '4202581', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1353, 'n_words': 283}