CsvImporter::loadOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 9.9666
cc 1
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\LaravelExcel\Importers;
2
3
use Box\Spout\Common\Type;
4
5
/**
6
 * Class     CsvImporter
7
 *
8
 * @package  Arcanedev\LaravelExcel\Importer
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class CsvImporter extends AbstractImporter
12
{
13
    /* -----------------------------------------------------------------
14
     |  Properties
15
     | -----------------------------------------------------------------
16
     */
17
18
    /** @var  string */
19
    protected $type = Type::CSV;
20
21
    /** @var \Box\Spout\Reader\CSV\Reader */
22
    protected $reader;
23
24
    /* -----------------------------------------------------------------
25
     |  Other Functions
26
     | -----------------------------------------------------------------
27
     */
28
29
    /**
30
     * Load the reader options.
31
     */
32 6
    protected function loadOptions()
33
    {
34 6
        $this->reader
35 6
             ->setFieldDelimiter($this->getOption('field-delimiter', ','))
36 6
             ->setFieldEnclosure($this->getOption('field-enclosure', '"'))
37 6
             ->setEndOfLineCharacter($this->getOption('eol-character', "\n"))
38 6
             ->setEncoding($this->getOption('encoding', 'UTF-8'))
39 6
             ->setShouldPreserveEmptyRows($this->getOption('preserve-empty-rows', false));
40 6
    }
41
}
42