Simple csv file parsing in Symfony Command class

Sometimes, in a Symfony command, you could have to parse a .csv file for example to put some datas in database. This is a small snippet (a function) that reads a comma separated values file and returns a php array, usable in a command (or other places).

Command class

The mechanism in divided into two parts: an array of options and a parseCSV() function. Here is the code:

class ImportationCommand extends ContainerAwareCommand
{
    // change these options about the file to read
    private $csvParsingOptions = array(
        'finder_in' => 'app/Resources/',
        'finder_name' => 'fixtures.csv',
        'ignoreFirstLine' => true
    );

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        [...]

        // use the parseCSV() function
        $csv = $this->parseCSV();
    }

    /**
     * Parse a csv file
     * 
     * @return array
     */
    private function parseCSV()
    {
        $ignoreFirstLine = $this->csvParsingOptions['ignoreFirstLine'];

        $finder = new Finder();
        $finder->files()
            ->in($this->csvParsingOptions['finder_in'])
            ->name($this->csvParsingOptions['finder_name'])
        ;
        foreach ($finder as $file) { $csv = $file; }

        $rows = array();
        if (($handle = fopen($csv->getRealPath(), "r")) !== FALSE) {
            $i = 0;
            while (($data = fgetcsv($handle, null, ";")) !== FALSE) {
                $i++;
                if ($ignoreFirstLine && $i == 1) { continue; }
                $rows[] = $data;
            }
            fclose($handle);
        }

        return $rows;
    }
}