<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$
 */
 
  uses(
    'lang.System',
    'io.File',
    'io.FileUtil',
    'util.Hashmap',
    'util.registry.storage.RegistryStorage'
  );
  
  /**
   * DBA storage
   *
   * @purpose  A storage provider that uses flat files
   * @see      php://serialize
   */
  class FlatfileStorage extends RegistryStorage {
    var
      $_file   = NULL;

    /**
     * Initialize this storage
     *
     * @access  public
     */
    function initialize() {
      $this->_file= &new File(System::tempDir().$this->id.'.dat');
      if ($this->_file->exists()) {
        touch($this->_file->getURI());
        $this->_hash= &new Hashmap();
      } else {
        $this->_hash= unserialize(FileUtil::getContents($this->_file));
      }    
    }
    
    /**
     * Returns whether this storage contains the given key
     *
     * @access  public
     * @param   string key
     * @return  bool TRUE when this key exists
     */
    function contains($key) {
      return $this->_hash->containsKey($key);
    }

    /**
     * Get all keys
     *
     * @access  public
     * @return  string[] key<commit_msg>- System::tempDir() does not include a trailing slash - Fix condition in if() clause<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$
 */
 
  uses(
    'lang.System',
    'io.File',
    'io.FileUtil',
    'util.Hashmap',
    'util.registry.storage.RegistryStorage'
  );
  
  /**
   * DBA storage
   *
   * @purpose  A storage provider that uses flat files
   * @see      php://serialize
   */
  class FlatfileStorage extends RegistryStorage {
    var
      $_file   = NULL;

    /**
     * Initialize this storage
     *
     * @access  public
     */
    function initialize() {
      $this->_file= &new File(System::tempDir().DIRECTORY_SEPARATOR.$this->id.'.dat');
      if (!$this->_file->exists()) {
        touch($this->_file->getURI());
        $this->_hash= &new Hashmap();
      } else {
        $this->_hash= unserialize(FileUtil::getContents($this->_file));
      }    
    }
    
    /**
     * Returns whether this storage contains the given key
     *
     * @access  public
     * @param   string key
     * @return  bool TRUE when this key exists
     */
    function contains($key) {
      return $this->_hash->containsKey($key);
    }

    /**
     * Get all keys
     *
     * @access  public
     * @return  string[] key
{'fraction_non_alphanumeric': 0.14473684210526316, 'fraction_numerical': 0.0, 'mean_word_length': 2.022360248447205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '6611015', 'n_tokens_mistral': 756, 'n_tokens_neox': 738, 'n_words': 183}