public function setOption($name, $value)
    {
        if (! in_array($name, $this->validOptions)) {
            throw new Error('Invalid option ' . $name . '. Valid options are : ' . join(', ', $this->validOptions));
        }
        // Check duplicate fields in header
        if ('header' == $name) {
            $cnt = array_count_values($value);
            $duplicates = array();
            foreach ($cnt as $f => $c) {
                if ($c > 1) {
                    $duplicates[$f] = $c;
                }
            }
            if (sizeof($duplicates) > 0) {
                $msg = 'Duplicate fields found in header : ' . join(', ', array_keys($duplicates));
                throw new Error($msg);
            }
        }
        $this->$name = $value;

        return $this;
    }
public function setOption($name, $value)
    {
        if (! in_array($name, $this->validOptions)) {
            throw new Error('Invalid option ' . $name . '. Valid options are : ' . join(', ', $this->validOptions));
        }
        // Check duplicate fields in header
        if ('header' == $name) {
            $cnt = array_count_values($value);
            $duplicates = array();
            foreach ($cnt as $f => $c) {
                if ($c > 1) {
                    $duplicates[$f] = $c;
                }
            }
            if (sizeof($duplicates) > 0) {
                $msg = 'Duplicate fields found in header : ' . join(', ', array_keys($duplicates));
                throw new Error($msg);
            }
        }
        $this->$name = $value;

        return $this;
    }
public function setOption ( $ name , $ value ) { if ( ! in_array ( $ name , $ this -> validOptions ) ) { throw new Error ( 'Invalid option ' . $ name . '. Valid options are : ' . join ( ', ' , $ this -> validOptions ) ) ; } // Check duplicate fields in header if ( 'header' == $ name ) { $ cnt = array_count_values ( $ value ) ; $ duplicates = array ( ) ; foreach ( $ cnt as $ f => $ c ) { if ( $ c > 1 ) { $ duplicates [ $ f ] = $ c ; } } if ( sizeof ( $ duplicates ) > 0 ) { $ msg = 'Duplicate fields found in header : ' . join ( ', ' , array_keys ( $ duplicates ) ) ; throw new Error ( $ msg ) ; } } $ this -> $ name = $ value ; return $ this ; }
Sets an option

@param string $name
@param mixed  $value

@return Csv\Reader

@throws Csv\Error
Sets an option