<commit_before><?php

namespace Kothman;

class CSVParser
{

    protected $resource = null;
    protected $options = null;

    /**
     * Create a new CSVParser instance
     *
     * @param string $path A URL or file.
     * @param string $delimiter
     * @param int $length
     * @param string $enclosure
     * @param string $escape
     */
    public function __construct($path,
    	    	     		$delimiter = null,
			 	$length = null,
				$enclosure = null,
				$escape = null)
    {
        if (!$this->load($path)) {
	    throw new Exception('Unable to load resource: ' . $path);
        }
	$this->options = new \Kothman\CSVParserOptions($delimiter, $length, $enclosure, $escape);
    }

    /**
     * Load a resource to be used by the parser
     *
     * @param string $path A URL or file.
     * @return bool Indicate success or failiure
     */ 
     private function load($path)
     {
	$this->resource = fopen($path, 'r');
	return $this->resource?true:false;
     }

    /**
     * Called at the begining of any function that uses $resource
     *
     * @return void
     */
     protected function check() {
         if(!$this->resource) {
	     throw new Exception('The CSVParser does not have a loaded resource.');
	 }
     }

    /**
     * Set various options that get passed to fgetcsv in CSVParser::row
     *
     * See http://php.net/manual/en/function.fgetcsv.php for more info
     *
     * @param array $options length, delimiter, enclosure, escape.
     * @return void
     */
     public function set($options) {
	 $this->length = $options['length'] || $this->length;
	 $this->delimiter = $options['delimiter'] || $this->delimiter;
	 $this->enclosure = $options['enclosure'] || $this->enclosure;
	 $this->escape = $options['escape'] || $this->escape;
     }

    /**
     * Return the next row of the CSV file
     *
     * @return array | false
     */
     public function row() {
         $this->check();
	 $data = fgetcsv($this->resource,
			 $this->options->length,<commit_msg>Remove unnecessary 'set' function<commit_after><?php

namespace Kothman;

class CSVParser
{

    protected $resource = null;
    protected $options = null;

    /**
     * Create a new CSVParser instance
     *
     * @param string $path A URL or file.
     * @param string $delimiter
     * @param int $length
     * @param string $enclosure
     * @param string $escape
     */
    public function __construct($path,
    	    	     		$delimiter = null,
			 	$length = null,
				$enclosure = null,
				$escape = null)
    {
        if (!$this->load($path)) {
	    throw new Exception('Unable to load resource: ' . $path);
        }
	$this->options = new \Kothman\CSVParserOptions($delimiter, $length, $enclosure, $escape);
    }

    /**
     * Load a resource to be used by the parser
     *
     * @param string $path A URL or file.
     * @return bool Indicate success or failiure
     */ 
     private function load($path)
     {
	$this->resource = fopen($path, 'r');
	return $this->resource?true:false;
     }

    /**
     * Called at the begining of any function that uses $resource
     *
     * @return void
     */
     protected function check() {
         if(!$this->resource) {
	     throw new Exception('The CSVParser does not have a loaded resource.');
	 }
     }

    /**
     * Return the next row of the CSV file
     *
     * @return array | false
     */
     public function row() {
         $this->check();
	 $data = fgetcsv($this->resource,
			 $this->options->length,
{'fraction_non_alphanumeric': 0.1317365269461078, 'fraction_numerical': 0.0, 'mean_word_length': 2.248148148148148, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '5350140', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1051, 'n_words': 311}