Writer::writeLine()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Tleckie\Csv;
4
5
use Tleckie\Csv\Writer\WriterInterface;
6
7
/**
8
 * Class Writer
9
 *
10
 * @package Tleckie\Csv
11
 * @author  Teodoro Leckie Westberg <[email protected]>
12
 */
13
class Writer extends CsvAbstract implements WriterInterface
14
{
15
    /**
16
     * Writer constructor.
17
     *
18
     * @param string $file
19
     * @param string $separator
20
     * @param string $enclosure
21
     * @param string $escape
22
     * @param string $mode
23
     */
24
    public function __construct(
25
        string $file,
26
        string $separator = ',',
27
        string $enclosure = '"',
28
        string $escape = "\\",
29
        string $mode = "a+"
30
    ) {
31
        parent::__construct($file, $separator, $enclosure, $escape, $mode);
32
    }
33
34
    /**
35
     * @inheritdoc
36
     */
37
    public function writeLine(RowInterface|array $row): bool
38
    {
39
        return $this->fputcsv(
40
            $row instanceof RowInterface ? $row->toArray() : $row
41
        );
42
    }
43
}
44