Test Failed
Push — master ( 4d08be...259b26 )
by Andrew
01:16
created

FileWriter::write()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2.032
1
<?php
2
3
namespace CsvParser\Writer;
4
use CsvParser\Exception;
5
6
class FileWriter implements WriterInterface
7
{
8 1
    public static function write(\CsvParser\Parser $parser, \CsvParser\Csv $csv, $filename='')
9
    {
10 1
        if ( ! $filename) {
11
            throw new Exception('Please provide a file name to write to');
12
        }
13 1
        $file = $parser->toString($csv);
14 1
        return file_put_contents($filename, $file);
15
    }
16
}
17