Coseva\CSV::__construct PHP Méthode

__construct() public méthode

To read a csv file, just pass the path to the .csv file.
See also: http://php.net/manual/en/function.fopen.php for a list of modes
public __construct ( string $filename, string $open_mode = 'r', boolean $use_include_path = false ) : CSV
$filename string The file to read. Should be readable.
$open_mode string The mode in which to open the file
$use_include_path boolean Whether to search through include_path
Résultat CSV $this
    public function __construct($filename, $open_mode = 'r', $use_include_path = false)
    {
        // Check if the given filename was readable.
        if (!$this->_resolveFilename($filename, $use_include_path)) {
            throw new InvalidArgumentException(var_export($filename, true) . ' is not readable.');
        }
        // Check if the given open mode was valid.
        if (!in_array($open_mode, self::$_availableOpenModes)) {
            throw new InvalidArgumentException('Unknown open mode ' . var_export($open_mode, true) . '.');
        }
        // Store the configuration.
        $this->_fileConfig = array('filename' => $filename, 'open_mode' => $open_mode, 'use_include_path' => (bool) $use_include_path, 'delimiter' => ',');
        // Try to automatically determine the most optimal settings for this file.
        // First we clear the stat cache to have a better prediction.
        clearstatcache(false, $filename);
        $fsize = filesize($filename);
        $malloc = memory_get_usage();
        $mlimit = (int) ini_get('memory_limit');
        // We have memory to spare. Make use of that.
        if ($mlimit < 0 || $mlimit - $malloc > $fsize * 2) {
            $this->_garbageCollection = false;
        }
        // If the file is large, flush empty rows to improve filter speed.
        if ($fsize > 1000000.0) {
            $this->_flushOnAfterFilter = true;
        }
    }